Merge pull request #1628 from 0xProject/fix/pipeline/fix-test-db-incorrectly-named-constraint

Fix inconsistently named constraint in migration
This commit is contained in:
Francesco Agosti
2019-02-20 17:17:16 -08:00
committed by GitHub

View File

@@ -21,8 +21,8 @@ export class TokenOrderBookSnapshotsAddMakerAddress1550163069315 implements Migr
`);
await queryRunner.query(`
ALTER TABLE ${TOKEN_ORDERBOOK_SNAPSHOT_TABLE}
DROP CONSTRAINT "token_orderbook_snapshots_pkey1",
ADD PRIMARY KEY (observed_timestamp, source, order_type, price, base_asset_symbol, quote_asset_symbol, maker_address);
DROP CONSTRAINT "token_orderbook_snapshots_pkey",
ADD CONSTRAINT "token_orderbook_snapshots_pkey" PRIMARY KEY (observed_timestamp, source, order_type, price, base_asset_symbol, quote_asset_symbol, maker_address);
`);
} else {
throw new Error(`Could not find table with name ${TOKEN_ORDERBOOK_SNAPSHOT_TABLE}`);
@@ -32,7 +32,12 @@ export class TokenOrderBookSnapshotsAddMakerAddress1550163069315 implements Migr
public async down(queryRunner: QueryRunner): Promise<any> {
const snapshotTable = await queryRunner.getTable(TOKEN_ORDERBOOK_SNAPSHOT_TABLE);
if (snapshotTable) {
await queryRunner.dropColumn(snapshotTable, NEW_COLUMN_NAME);
await queryRunner.query(`
ALTER TABLE ${TOKEN_ORDERBOOK_SNAPSHOT_TABLE}
DROP CONSTRAINT "token_orderbook_snapshots_pkey",
DROP COLUMN ${NEW_COLUMN_NAME},
ADD CONSTRAINT "token_orderbook_snapshots_pkey" PRIMARY KEY (observed_timestamp, source, order_type, price, base_asset_symbol, quote_asset_symbol);
`);
} else {
throw new Error(`Could not find table with name ${TOKEN_ORDERBOOK_SNAPSHOT_TABLE}`);
}