Skip to content

Commit

Permalink
stats-updater: Fix Dockerfile
Browse files Browse the repository at this point in the history
  • Loading branch information
bperel committed Aug 18, 2024
1 parent a9df2e9 commit 093ab6b
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 5 deletions.
2 changes: 2 additions & 0 deletions apps/stats-updater/.env
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,5 @@ MYSQL_COA_DATABASE=coa
DATABASE_URL_COA=mysql://root:changeme@localhost:64999/coa
DATABASE_URL_DM=mysql://root:changeme@localhost:64999/dm
DATABASE_URL_DM_STATS=mysql://root:changeme@localhost:64999/dm_stats

DM_STATS_DDL_PATH=../../packages/prisma-schemas/schemas/dm_stats/migrations/0_init/migration.sql
1 change: 1 addition & 0 deletions apps/stats-updater/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ COPY apps/stats-updater/bundle.mjs /app/
COPY packages/prisma-schemas/client_coa/ /client_coa
COPY packages/prisma-schemas/client_dm/ /client_dm
COPY packages/prisma-schemas/client_dm_stats/ /client_dm_stats
COPY packages/prisma-schemas/schema/dm_stats/migrations/0_init/migration.sql dm-stats-ddl.sql

EXPOSE 3000
ENTRYPOINT ["bun", "bundle.mjs"]
4 changes: 2 additions & 2 deletions apps/stats-updater/db.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,5 +69,5 @@ export const runQuery = async (sql: string) => {
return await connection.query(sql);
};

export const runQueryFile = async (sqlFile: string) =>
runQuery(readFileSync(sqlFile).toString());
export const runQueryFile = async (dbName: string, sqlFile: string) =>
runQuery(`USE ${dbName};` + readFileSync(sqlFile).toString());
4 changes: 1 addition & 3 deletions apps/stats-updater/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,7 @@ db.connect().then(async () => {
await db.runQuery(`DROP DATABASE IF EXISTS ${dbName}_new`);
await db.runQuery(`CREATE DATABASE ${dbName}_new`);



await db.runMigrations();
await db.runQueryFile(`${dbName}_new`, process.env.DM_STATS_DDL_PATH);

const authorUsers = await prismaDm.authorUser.findMany({
where: {
Expand Down

0 comments on commit 093ab6b

Please sign in to comment.