// @flow

import { dbQuery, SQL } from '../database/database';
import { main } from './utils';

async function addIndexes() {
  await dbQuery(SQL`
    ALTER TABLE memberships ADD INDEX user (user);
    ALTER TABLE notifications ADD INDEX user (user);
    ALTER TABLE relationships_directed ADD UNIQUE user2_user1 (user2, user1);
  `);
}

main([addIndexes]);

// @flow

import { dbQuery, SQL } from '../database/database';
import { setScriptContext } from './script-context';
import { main } from './utils';

setScriptContext({
  allowMultiStatementSQLQueries: true,
});

async function addIndexes() {
  await dbQuery(SQL`
    ALTER TABLE memberships ADD INDEX user (user);
    ALTER TABLE notifications ADD INDEX user (user);
    ALTER TABLE relationships_directed ADD UNIQUE user2_user1 (user2, user1);
  `);
}

main([addIndexes]);

Use multipleStatements mode in account deletion indexes script
[server] Use multipleStatements mode in account deletion indexes script

Summary: Without multipleStatements mode an error is returned `You have an error in your SQL syntax...`. Enabling multipleStatements fixes the issue.

Test Plan: Run the script and check if indexes were added

Reviewers: ashoat

Reviewed By: ashoat

Subscribers: KatPo, Adrian, atul

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