mirror of
https://github.com/fosrl/pangolin.git
synced 2025-07-24 12:44:59 +02:00
first readme
This commit is contained in:
parent
3b4a993704
commit
3672d783fd
10 changed files with 146 additions and 8 deletions
|
@ -1,7 +1,7 @@
|
|||
import { db } from "@server/db";
|
||||
import { orgs } from "../db/schema";
|
||||
import { orgs, resources } from "../db/schema";
|
||||
import config from "@server/lib/config";
|
||||
import { ne } from "drizzle-orm";
|
||||
import { eq, ne } from "drizzle-orm";
|
||||
import logger from "@server/logger";
|
||||
|
||||
export async function copyInConfig() {
|
||||
|
@ -11,5 +11,19 @@ export async function copyInConfig() {
|
|||
// update the domain on all of the orgs where the domain is not equal to the new domain
|
||||
// TODO: eventually each org could have a unique domain that we do not want to overwrite, so this will be unnecessary
|
||||
await db.update(orgs).set({ domain }).where(ne(orgs.domain, domain));
|
||||
|
||||
// update all resources fullDomain to use the new domain
|
||||
await db.transaction(async (trx) => {
|
||||
const allResources = await trx.select().from(resources);
|
||||
|
||||
for (const resource of allResources) {
|
||||
const fullDomain = `${resource.subdomain}.${domain}`;
|
||||
await trx
|
||||
.update(resources)
|
||||
.set({ fullDomain })
|
||||
.where(eq(resources.resourceId, resource.resourceId));
|
||||
}
|
||||
});
|
||||
|
||||
logger.info(`Updated orgs with new domain (${domain})`);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue