fixed twenty website build (#5174)

Made code compile during build even when then environment variable is
not yet available

Co-authored-by: Ady Beraud <a.beraud96@gmail.com>
This commit is contained in:
Ady Beraud
2024-04-25 16:54:54 +03:00
committed by GitHub
parent d23e02adca
commit 6e8c6c8e58
9 changed files with 23 additions and 3 deletions

View File

@ -1,12 +1,16 @@
import { global } from '@apollo/client/utilities/globals';
import { drizzle } from 'drizzle-orm/postgres-js';
import { drizzle, PostgresJsDatabase } from 'drizzle-orm/postgres-js';
import { migrate as postgresMigrate } from 'drizzle-orm/postgres-js/migrator';
import postgres from 'postgres';
import 'dotenv/config';
const pgClient = postgres(`${global.process.env.DATABASE_PG_URL}`);
const pgDb = drizzle(pgClient, { logger: false });
let pgDb: PostgresJsDatabase;
if (global.process.env.DATABASE_PG_URL) {
const pgClient = postgres(`${global.process.env.DATABASE_PG_URL}`);
pgDb = drizzle(pgClient, { logger: false });
}
const migrate = async () => {
await postgresMigrate(pgDb, {