Setting up calculator config management
This commit is contained in:
@@ -20,12 +20,27 @@ export async function up(db: Kysely<any>): Promise<void> {
|
||||
// INDEX: ONE_ACTIVE_PRODUCT_SYNC
|
||||
await db.schema.createIndex("idx_one_active_product_sync")
|
||||
.on("product_syncs")
|
||||
.unique()
|
||||
.column("ended_at")
|
||||
.unique()
|
||||
.where(sql.ref("started_at"), "is not", null)
|
||||
.where("ended_at", "is", null)
|
||||
.nullsNotDistinct()
|
||||
.execute();
|
||||
|
||||
// TABLE: CALCULATOR_CONFIGS
|
||||
await db.schema.createTable("calculator_configs")
|
||||
.$call(addDefaultColumns)
|
||||
.addColumn("parameters", "jsonb", (cb) => cb.notNull())
|
||||
.addColumn("is_selected", "boolean", (cb) => cb.notNull())
|
||||
.execute();
|
||||
|
||||
// INDEX: ONE_SELECTED_CALCULATOR_CONFIG
|
||||
await db.schema.createIndex("idx_one_selected_calculator_config")
|
||||
.on("calculator_configs")
|
||||
.column("is_selected")
|
||||
.unique()
|
||||
.where("is_selected", "=", true)
|
||||
.execute();
|
||||
}
|
||||
|
||||
export async function down(db: Kysely<any>): Promise<void> {
|
||||
@@ -34,4 +49,10 @@ export async function down(db: Kysely<any>): Promise<void> {
|
||||
|
||||
// INDEX: ONE_ACTIVE_PRODUCT_SYNC
|
||||
await db.schema.dropIndex("idx_one_active_product_sync").ifExists().execute();
|
||||
|
||||
// TABLE: CALCULATOR_CONFIGS
|
||||
await db.schema.dropTable("calculator_configs").ifExists().execute()
|
||||
|
||||
// INDEX: ONE_SELECTED_CALCULATOR_CONFIG
|
||||
await db.schema.dropIndex("idx_one_selected_calculator_config").ifExists().execute();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user