mirror of
https://github.com/fosrl/pangolin.git
synced 2026-03-01 08:16:44 +00:00
Update migrations
This commit is contained in:
@@ -16,13 +16,31 @@ export default async function migration() {
|
|||||||
|
|
||||||
await db.execute(sql`BEGIN`);
|
await db.execute(sql`BEGIN`);
|
||||||
|
|
||||||
await db.execute(sql`ALTER TABLE "exitNodes" ADD COLUMN "region" text;`);
|
await db.execute(
|
||||||
|
sql`ALTER TABLE "exitNodes" ADD COLUMN "region" text;`
|
||||||
await db.execute(sql`ALTER TABLE "idpOidcConfig" ADD COLUMN "variant" text DEFAULT 'oidc' NOT NULL;`);
|
);
|
||||||
|
|
||||||
await db.execute(sql`ALTER TABLE "resources" ADD COLUMN "niceId" text DEFAULT '' NOT NULL;`);
|
await db.execute(
|
||||||
|
sql`ALTER TABLE "idpOidcConfig" ADD COLUMN "variant" text DEFAULT 'oidc' NOT NULL;`
|
||||||
await db.execute(sql`ALTER TABLE "userOrgs" ADD COLUMN "autoProvisioned" boolean DEFAULT false;`);
|
);
|
||||||
|
|
||||||
|
await db.execute(
|
||||||
|
sql`ALTER TABLE "resources" ADD COLUMN "niceId" text DEFAULT '' NOT NULL;`
|
||||||
|
);
|
||||||
|
|
||||||
|
await db.execute(
|
||||||
|
sql`ALTER TABLE "userOrgs" ADD COLUMN "autoProvisioned" boolean DEFAULT false;`
|
||||||
|
);
|
||||||
|
|
||||||
|
await db.execute(
|
||||||
|
sql`ALTER TABLE "targets" ADD COLUMN "pathMatchType" text;`
|
||||||
|
);
|
||||||
|
|
||||||
|
await db.execute(sql`ALTER TABLE "targets" ADD COLUMN "path" text;`);
|
||||||
|
|
||||||
|
await db.execute(
|
||||||
|
sql`ALTER TABLE "resources" ADD COLUMN "headers" text;`
|
||||||
|
);
|
||||||
|
|
||||||
const usedNiceIds: string[] = [];
|
const usedNiceIds: string[] = [];
|
||||||
|
|
||||||
|
|||||||
@@ -12,14 +12,14 @@ export default async function migration() {
|
|||||||
const db = new Database(location);
|
const db = new Database(location);
|
||||||
|
|
||||||
const resourceSiteMap = new Map<number, number>();
|
const resourceSiteMap = new Map<number, number>();
|
||||||
const firstSiteId: number = 1;
|
const firstSiteId: number = 1;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const resources = db
|
const resources = db
|
||||||
.prepare(
|
.prepare(
|
||||||
"SELECT resourceId FROM resources WHERE siteId IS NOT NULL"
|
"SELECT resourceId FROM resources WHERE siteId IS NOT NULL"
|
||||||
)
|
)
|
||||||
.all() as Array<{ resourceId: number; }>;
|
.all() as Array<{ resourceId: number }>;
|
||||||
|
|
||||||
db.transaction(() => {
|
db.transaction(() => {
|
||||||
db.exec(`
|
db.exec(`
|
||||||
@@ -27,6 +27,9 @@ export default async function migration() {
|
|||||||
ALTER TABLE 'idpOidcConfig' ADD 'variant' text DEFAULT 'oidc' NOT NULL;
|
ALTER TABLE 'idpOidcConfig' ADD 'variant' text DEFAULT 'oidc' NOT NULL;
|
||||||
ALTER TABLE 'resources' ADD 'niceId' text DEFAULT '' NOT NULL;
|
ALTER TABLE 'resources' ADD 'niceId' text DEFAULT '' NOT NULL;
|
||||||
ALTER TABLE 'userOrgs' ADD 'autoProvisioned' integer DEFAULT false;
|
ALTER TABLE 'userOrgs' ADD 'autoProvisioned' integer DEFAULT false;
|
||||||
|
ALTER TABLE 'targets' ADD 'pathMatchType' text;
|
||||||
|
ALTER TABLE 'targets' ADD 'path' text;
|
||||||
|
ALTER TABLE 'resources' ADD 'headers' text;
|
||||||
`); // this diverges from the schema a bit because the schema does not have a default on niceId but was required for the migration and I dont think it will effect much down the line...
|
`); // this diverges from the schema a bit because the schema does not have a default on niceId but was required for the migration and I dont think it will effect much down the line...
|
||||||
|
|
||||||
const usedNiceIds: string[] = [];
|
const usedNiceIds: string[] = [];
|
||||||
@@ -47,7 +50,9 @@ export default async function migration() {
|
|||||||
}
|
}
|
||||||
loops++;
|
loops++;
|
||||||
}
|
}
|
||||||
db.prepare(`UPDATE resources SET niceId = ? WHERE resourceId = ?`).run(niceId, resourceId.resourceId);
|
db.prepare(
|
||||||
|
`UPDATE resources SET niceId = ? WHERE resourceId = ?`
|
||||||
|
).run(niceId, resourceId.resourceId);
|
||||||
}
|
}
|
||||||
})();
|
})();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user