Files
cfw-autumn/shared/models/migrationModels/migrationJobTable.ts
John Yeo cb05d169a2 wip
2026-01-23 17:13:19 +00:00

37 lines
1.1 KiB
TypeScript

import { foreignKey, jsonb, numeric, pgTable, text } from "drizzle-orm/pg-core";
import { organizations } from "../orgModels/orgTable.js";
import { products } from "../productModels/productTable.js";
export const migrationJobs = pgTable(
"migration_jobs",
{
id: text().primaryKey().notNull(),
org_id: text().notNull(),
env: text().notNull(),
created_at: numeric({ mode: "number" }).notNull(),
updated_at: numeric({ mode: "number" }),
current_step: text(),
from_internal_product_id: text(),
to_internal_product_id: text(),
step_details: jsonb(),
},
(table) => [
foreignKey({
columns: [table.from_internal_product_id],
foreignColumns: [products.internal_id],
name: "migration_jobs_from_internal_product_id_fkey",
}).onDelete("cascade"),
foreignKey({
columns: [table.org_id],
foreignColumns: [organizations.id],
name: "migration_jobs_org_id_fkey",
}).onDelete("cascade"),
foreignKey({
columns: [table.to_internal_product_id],
foreignColumns: [products.internal_id],
name: "migration_jobs_to_internal_product_id_fkey",
}).onDelete("cascade"),
],
);