fosrl.pangolin/server/setup/copyInConfig.ts

16 lines
698 B
TypeScript
Raw Normal View History

2024-12-22 12:23:19 -05:00
import { db } from "@server/db";
import { orgs } from "../db/schema";
2025-01-01 21:41:31 -05:00
import config from "@server/lib/config";
2024-12-22 12:23:19 -05:00
import { ne } from "drizzle-orm";
import logger from "@server/logger";
export async function copyInConfig() {
// create a url from config.getRawConfig().app.base_url and get the hostname
const domain = config.getBaseDomain();
2024-12-25 15:54:32 -05:00
2024-12-22 12:23:19 -05:00
// 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));
2024-12-25 15:54:32 -05:00
logger.info(`Updated orgs with new domain (${domain})`);
}