More refactoring and integration of standards dataset database
This commit is contained in:
@@ -16,7 +16,7 @@ function processResults(label: string, { error, results }: MigrationResultSet):
|
||||
if (it.status === 'Success') {
|
||||
message = `migration ${label} succeeded: "${it.migrationName}"`;
|
||||
} else if (it.status === 'Error') {
|
||||
throw new Error(`migration ${label} failed: "${it.migrationName}"`);
|
||||
throw error ?? new Error(`migration ${label} failed: "${it.migrationName}"`);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -27,11 +27,27 @@ export async function up(db: Kysely<any>): Promise<void> {
|
||||
.nullsNotDistinct()
|
||||
.execute();
|
||||
|
||||
// TABLE: STANDARDS_DATASETS
|
||||
await db.schema.createTable("standards_datasets")
|
||||
.$call(addDefaultColumns)
|
||||
.addColumn("name", "text", (cb) => cb.notNull().defaultTo(""))
|
||||
.addColumn("data", "jsonb", (cb) => cb.notNull())
|
||||
.execute();
|
||||
|
||||
// TABLE: STANDARDS_CONFIGS
|
||||
await db.schema.createTable("standards_configs")
|
||||
.$call(addDefaultColumns)
|
||||
.addColumn("name", "text", (cb) => cb.notNull().defaultTo(""))
|
||||
.addColumn("parameters", "jsonb", (cb) => cb.notNull())
|
||||
.addColumn("is_selected", "boolean", (cb) => cb.notNull().defaultTo(false))
|
||||
.addColumn("dataset_id", "bigint", (cb) => cb.notNull())
|
||||
.addForeignKeyConstraint(
|
||||
"fk_standards_configs_dataset_id",
|
||||
["dataset_id"],
|
||||
"standards_datasets",
|
||||
["id"],
|
||||
(cb) => cb.onDelete("restrict")
|
||||
)
|
||||
.execute();
|
||||
|
||||
// INDEX: ONE_SELECTED_STANDARDS_CONFIG
|
||||
@@ -50,9 +66,12 @@ 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();
|
||||
|
||||
// INDEX: ONE_SELECTED_STANDARDS_CONFIG
|
||||
await db.schema.dropIndex("idx_one_selected_standards_config").ifExists().execute();
|
||||
|
||||
// TABLE: STANDARDS_CONFIGS
|
||||
await db.schema.dropTable("standards_configs").ifExists().execute()
|
||||
|
||||
// INDEX: ONE_SELECTED_STANDARDS_CONFIG
|
||||
await db.schema.dropIndex("idx_one_selected_standards_config").ifExists().execute();
|
||||
// TABLE: STANDARDS_DATASETS
|
||||
await db.schema.dropTable("standards_datasets").ifExists().execute()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user