HomePhabricator
Diffusion Comm 76832821bfb4

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

Description

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

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

Reviewers: palys-swm, atul

Reviewed By: palys-swm

Subscribers: Adrian, yayabosh

Differential Revision: https://phabricator.ashoat.com/D4141