Add blueprints to migrations

This commit is contained in:
Owen
2025-10-29 20:50:36 -07:00
parent 0e51bac307
commit 927dda4e53
2 changed files with 32 additions and 0 deletions

View File

@@ -79,6 +79,21 @@ export default async function migration() {
);
`);
await db.execute(sql`
CREATE TABLE "blueprints" (
"blueprintId" serial PRIMARY KEY NOT NULL,
"orgId" text NOT NULL,
"name" varchar NOT NULL,
"source" varchar NOT NULL,
"createdAt" integer NOT NULL,
"succeeded" boolean NOT NULL,
"contents" text NOT NULL,
"message" text
);
`);
await db.execute(sql`ALTER TABLE "blueprints" ADD CONSTRAINT "blueprints_orgId_orgs_orgId_fk" FOREIGN KEY ("orgId") REFERENCES "public"."orgs"("orgId") ON DELETE cascade ON UPDATE no action;`);
await db.execute(sql`ALTER TABLE "resources" DROP CONSTRAINT "resources_skipToIdpId_idp_idpId_fk";`);
await db.execute(sql`ALTER TABLE "domains" ADD COLUMN "certResolver" varchar;`);
await db.execute(sql`ALTER TABLE "domains" ADD COLUMN "customCertResolver" varchar;`);

View File

@@ -112,6 +112,23 @@ export default async function migration() {
`
).run();
db.prepare(
`
CREATE TABLE 'blueprints' (
'blueprintId' integer PRIMARY KEY AUTOINCREMENT NOT NULL,
'orgId' text NOT NULL,
'name' text NOT NULL,
'source' text NOT NULL,
'createdAt' integer NOT NULL,
'succeeded' integer NOT NULL,
'contents' text NOT NULL,
'message' text,
FOREIGN KEY ('orgId') REFERENCES 'orgs'('orgId') ON UPDATE no action ON DELETE cascade
);
`
).run();
db.prepare(
`CREATE INDEX 'idx_requestAuditLog_timestamp' ON 'requestAuditLog' ('timestamp');`
).run();