mirror of
https://github.com/fosrl/pangolin.git
synced 2026-02-16 09:56:36 +00:00
Various fixes
This commit is contained in:
@@ -107,6 +107,26 @@ export default async function migration() {
|
||||
await db.execute(sql`ALTER TABLE "resources" ADD CONSTRAINT "resources_skipToIdpId_idp_idpId_fk" FOREIGN KEY ("skipToIdpId") REFERENCES "public"."idp"("idpId") ON DELETE set null ON UPDATE no action;`);
|
||||
await db.execute(sql`ALTER TABLE "orgs" DROP COLUMN "settings";`);
|
||||
|
||||
|
||||
// get all of the domains
|
||||
const domainsQuery = await db.execute(sql`SELECT "domainId", "baseDomain" FROM "domains"`);
|
||||
const domains = domainsQuery.rows as {
|
||||
domainId: string;
|
||||
baseDomain: string;
|
||||
}[];
|
||||
|
||||
for (const domain of domains) {
|
||||
// insert two records into the dnsRecords table for each domain
|
||||
await db.execute(sql`
|
||||
INSERT INTO "dnsRecords" ("domainId", "recordType", "baseDomain", "value", "verified")
|
||||
VALUES (${domain.domainId}, 'A', ${`*.${domain.baseDomain}`}, ${'Server IP Address'}, true)
|
||||
`);
|
||||
await db.execute(sql`
|
||||
INSERT INTO "dnsRecords" ("domainId", "recordType", "baseDomain", "value", "verified")
|
||||
VALUES (${domain.domainId}, 'A', ${domain.baseDomain}, ${'Server IP Address'}, true)
|
||||
`);
|
||||
}
|
||||
|
||||
await db.execute(sql`COMMIT`);
|
||||
console.log("Migrated database");
|
||||
} catch (e) {
|
||||
|
||||
@@ -15,7 +15,7 @@ export default async function migration() {
|
||||
|
||||
db.transaction(() => {
|
||||
db.prepare(
|
||||
`UPDATE 'resourceRules' SET 'match' = 'COUNTRY' WHERE 'match' = 'GEOIP'`
|
||||
`UPDATE 'resourceRules' SET match = 'COUNTRY' WHERE match = 'GEOIP'`
|
||||
).run();
|
||||
|
||||
db.prepare(
|
||||
@@ -195,6 +195,29 @@ export default async function migration() {
|
||||
db.prepare(
|
||||
`ALTER TABLE 'user' ADD 'lastPasswordChange' integer;`
|
||||
).run();
|
||||
|
||||
// get all of the domains
|
||||
const domains = db.prepare(`SELECT domainId, baseDomain from domains`).all() as {
|
||||
domainId: number;
|
||||
baseDomain: string;
|
||||
}[];
|
||||
|
||||
for (const domain of domains) {
|
||||
// insert two records into the dnsRecords table for each domain
|
||||
const insert = db.prepare(
|
||||
`INSERT INTO 'dnsRecords' (domainId, recordType, baseDomain, value, verified) VALUES (?, 'A', ?, ?, 1)`
|
||||
);
|
||||
insert.run(
|
||||
domain.domainId,
|
||||
`*.${domain.baseDomain}`,
|
||||
`Server IP Address`
|
||||
);
|
||||
insert.run(
|
||||
domain.domainId,
|
||||
`${domain.baseDomain}`,
|
||||
`Server IP Address`
|
||||
);
|
||||
}
|
||||
})();
|
||||
|
||||
db.pragma("foreign_keys = ON");
|
||||
|
||||
Reference in New Issue
Block a user