-
Notifications
You must be signed in to change notification settings - Fork 124
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
12 additions
and
16 deletions.
There are no files selected for viewing
28 changes: 12 additions & 16 deletions
28
...res/src/db/migrations/migration_files/20231101173444_update_fills_type_with_deleverage.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,19 @@ | ||
import * as Knex from 'knex'; | ||
|
||
export async function up(knex: Knex): Promise<void> { | ||
return knex.raw(` | ||
ALTER TABLE ONLY fills | ||
DROP CONSTRAINT IF EXISTS fills_type_check; | ||
import { formatAlterTableEnumSql } from '../helpers'; | ||
|
||
ALTER TABLE ONLY fills | ||
ADD CONSTRAINT fills_type_check | ||
CHECK (type = ANY (ARRAY['MARKET'::text, 'LIMIT'::text, 'LIQUIDATED'::text, 'LIQUIDATION'::text, 'DELEVERAGED'::text, 'OFFSETTING'::text])); | ||
`); | ||
export async function up(knex: Knex): Promise<void> { | ||
return knex.raw(formatAlterTableEnumSql( | ||
'fills', | ||
'type', | ||
['MARKET', 'LIMIT', 'LIQUIDATED', 'LIQUIDATION', 'DELEVERAGED', 'OFFSETTING'], | ||
)); | ||
} | ||
|
||
export async function down(knex: Knex): Promise<void> { | ||
return knex.raw(` | ||
ALTER TABLE ONLY fills | ||
DROP CONSTRAINT IF EXISTS fills_type_check; | ||
ALTER TABLE ONLY fills | ||
ADD CONSTRAINT fills_type_check | ||
CHECK (type = ANY (ARRAY['MARKET'::text, 'LIMIT'::text, 'LIQUIDATED'::text, 'LIQUIDATION'::text])); | ||
`); | ||
return knex.raw(formatAlterTableEnumSql( | ||
'fills', | ||
'type', | ||
['MARKET', 'LIMIT', 'LIQUIDATED', 'LIQUIDATION'], | ||
)); | ||
} |