mirror of
https://github.com/fosrl/pangolin.git
synced 2026-07-06 12:19:50 +00:00
Move session migration out of the loop
This commit is contained in:
@@ -286,6 +286,24 @@ export default async function migration() {
|
|||||||
WHERE "resources"."resourceId" = "targets"."resourceId";
|
WHERE "resources"."resourceId" = "targets"."resourceId";
|
||||||
`);
|
`);
|
||||||
await db.execute(sql`ALTER TABLE "targets" ADD "authToken" text;`);
|
await db.execute(sql`ALTER TABLE "targets" ADD "authToken" text;`);
|
||||||
|
await db.execute(sql`
|
||||||
|
ALTER TABLE "resourceSessions" ADD COLUMN "policyPasswordId" integer;
|
||||||
|
`);
|
||||||
|
await db.execute(sql`
|
||||||
|
ALTER TABLE "resourceSessions" ADD COLUMN "policyPincodeId" integer;
|
||||||
|
`);
|
||||||
|
await db.execute(sql`
|
||||||
|
ALTER TABLE "resourceSessions" ADD COLUMN "policyWhitelistId" integer;
|
||||||
|
`);
|
||||||
|
await db.execute(sql`
|
||||||
|
ALTER TABLE "resourceSessions" ADD CONSTRAINT "resourceSessions_policyPasswordId_resourcePolicyPassword_passwordId_fk" FOREIGN KEY ("policyPasswordId") REFERENCES "public"."resourcePolicyPassword"("passwordId") ON DELETE cascade ON UPDATE no action;
|
||||||
|
`);
|
||||||
|
await db.execute(sql`
|
||||||
|
ALTER TABLE "resourceSessions" ADD CONSTRAINT "resourceSessions_policyPincodeId_resourcePolicyPincode_pincodeId_fk" FOREIGN KEY ("policyPincodeId") REFERENCES "public"."resourcePolicyPincode"("pincodeId") ON DELETE cascade ON UPDATE no action;
|
||||||
|
`);
|
||||||
|
await db.execute(sql`
|
||||||
|
ALTER TABLE "resourceSessions" ADD CONSTRAINT "resourceSessions_policyWhitelistId_resourcePolicyWhitelist_id_fk" FOREIGN KEY ("policyWhitelistId") REFERENCES "public"."resourcePolicyWhitelist"("id") ON DELETE cascade ON UPDATE no action;
|
||||||
|
`);
|
||||||
|
|
||||||
await db.execute(sql`COMMIT`);
|
await db.execute(sql`COMMIT`);
|
||||||
console.log("Migrated database");
|
console.log("Migrated database");
|
||||||
@@ -580,24 +598,6 @@ export default async function migration() {
|
|||||||
DELETE FROM "resourceWhitelist"
|
DELETE FROM "resourceWhitelist"
|
||||||
WHERE "resourceId" = ${resource.resourceId}
|
WHERE "resourceId" = ${resource.resourceId}
|
||||||
`);
|
`);
|
||||||
await db.execute(sql`
|
|
||||||
ALTER TABLE "resourceSessions" ADD COLUMN "policyPasswordId" integer;
|
|
||||||
`);
|
|
||||||
await db.execute(sql`
|
|
||||||
ALTER TABLE "resourceSessions" ADD COLUMN "policyPincodeId" integer;
|
|
||||||
`);
|
|
||||||
await db.execute(sql`
|
|
||||||
ALTER TABLE "resourceSessions" ADD COLUMN "policyWhitelistId" integer;
|
|
||||||
`);
|
|
||||||
await db.execute(sql`
|
|
||||||
ALTER TABLE "resourceSessions" ADD CONSTRAINT "resourceSessions_policyPasswordId_resourcePolicyPassword_passwordId_fk" FOREIGN KEY ("policyPasswordId") REFERENCES "public"."resourcePolicyPassword"("passwordId") ON DELETE cascade ON UPDATE no action;
|
|
||||||
`);
|
|
||||||
await db.execute(sql`
|
|
||||||
ALTER TABLE "resourceSessions" ADD CONSTRAINT "resourceSessions_policyPincodeId_resourcePolicyPincode_pincodeId_fk" FOREIGN KEY ("policyPincodeId") REFERENCES "public"."resourcePolicyPincode"("pincodeId") ON DELETE cascade ON UPDATE no action;
|
|
||||||
`);
|
|
||||||
await db.execute(sql`
|
|
||||||
ALTER TABLE "resourceSessions" ADD CONSTRAINT "resourceSessions_policyWhitelistId_resourcePolicyWhitelist_id_fk" FOREIGN KEY ("policyWhitelistId") REFERENCES "public"."resourcePolicyWhitelist"("id") ON DELETE cascade ON UPDATE no action;
|
|
||||||
`);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
await db.execute(sql`COMMIT`);
|
await db.execute(sql`COMMIT`);
|
||||||
|
|||||||
Reference in New Issue
Block a user