Skip to content

Commit

Permalink
stats-updater: Set missing DB URLs
Browse files Browse the repository at this point in the history
  • Loading branch information
bperel committed Aug 26, 2024
1 parent ce26e81 commit 71f5241
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions apps/stats-updater/.env
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
DATABASE_NAME_COA=coa
DATABASE_NAME_DM=dm
DATABASE_NAME_DM_STATS=dm_stats
DATABASE_URL_DM_STATS=mysql://root:changeme@localhost:64999/dm_stats_new

Expand Down
7 changes: 7 additions & 0 deletions apps/stats-updater/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ dotenv.config();
for (const envKey of [
"DATABASE_URL_DM_STATS",
"DATABASE_NAME_COA",
"DATABASE_NAME_DM",
"DATABASE_NAME_DM_STATS",
"DM_STATS_DDL_PATH",
]) {
Expand All @@ -34,14 +35,20 @@ for (const envKey of [

const { DATABASE_URL_DM_STATS,
DATABASE_NAME_COA,
DATABASE_NAME_DM,
DATABASE_NAME_DM_STATS,
DM_STATS_DDL_PATH } = process.env as {
DATABASE_URL_DM_STATS: string,
DATABASE_NAME_COA: string,
DATABASE_NAME_DM: string,
DATABASE_NAME_DM_STATS: string,
DM_STATS_DDL_PATH: string,
}

// These are required for the respective Prisma clients to work
process.env.DATABASE_URL_COA = DATABASE_URL_DM_STATS.replace(/\/[^/]+$/, `/${DATABASE_NAME_COA}`);
process.env.DATABASE_URL_DM = DATABASE_URL_DM_STATS.replace(/\/[^/]+$/, `/${DATABASE_NAME_DM}`);

const [_protocol, _username, MYSQL_ROOT_PASSWORD, MYSQL_HOST, MYSQL_PORT, DATABASE_NAME_DM_STATS_NEW] = (DATABASE_URL_DM_STATS).split(/\W+/)

const tables = [
Expand Down

0 comments on commit 71f5241

Please sign in to comment.