Page MenuHomePhabricator

[keyserver] Use multipleStatements option for individual queries in create-db.js
ClosedPublic

Authored by ashoat on May 26 2022, 12:53 PM.
Tags
None
Referenced Files
Unknown Object (File)
Mon, Nov 25, 4:02 PM
Unknown Object (File)
Sun, Nov 24, 2:32 AM
Unknown Object (File)
Wed, Nov 6, 6:14 AM
Unknown Object (File)
Wed, Nov 6, 6:14 AM
Unknown Object (File)
Wed, Nov 6, 6:14 AM
Unknown Object (File)
Wed, Nov 6, 6:14 AM
Unknown Object (File)
Oct 28 2024, 3:03 AM
Unknown Object (File)
Oct 28 2024, 3:03 AM

Details

Summary

Today, the only way to setup the MySQL database is via the create-db.js script. In a following diff, I'm working on making Node automatically setup the database if it is not set up.

In preparation for that, I'm moving the code in create-db.js to use the per-query { multipleStatements: true } option to dbQuery, instead of globally declaring setScriptContext({ allowMultiStatementSQLQueries: true, }).

This has the additional benefit of improving security for queries where we don't actually need multiple statements.

Test Plan
  1. mysql -uroot -p and then run CREATE DATABASE comm3; GRANT ALL ON comm3.* TO comm@localhost;
  2. Update keyserver/secrets/db_config.json to use the new comm3 database
  3. Run yarn dev or yarn prod-build in the keyserver directory
  4. mysql -uroot -p and then run USE comm3; SHOW TABLES; and see if the tables were all created

Diff Detail

Repository
rCOMM Comm
Lint
Lint Not Applicable
Unit
Tests Not Applicable