File tree Expand file tree Collapse file tree 2 files changed +9
-6
lines changed
Expand file tree Collapse file tree 2 files changed +9
-6
lines changed Original file line number Diff line number Diff line change @@ -18,7 +18,6 @@ FROM node:24-alpine
1818RUN corepack enable pnpm
1919WORKDIR /app
2020COPY --from=builder /app .
21- COPY --from=builder /build/packages/api/migrations /migrations
2221
2322USER node
2423EXPOSE 8080
Original file line number Diff line number Diff line change 1- import path from "node:path" ;
2- import { fileURLToPath } from "node:url" ;
31import { CollectionNotFoundError , DatabaseError } from "@nildb/common/errors" ;
42import type { AppBindings , EnvVars } from "@nildb/env" ;
53import type { UuidDto } from "@nillion/nildb-types" ;
@@ -82,15 +80,21 @@ export async function mongoMigrateUp(
8280 database : string ,
8381) : Promise < void > {
8482 console . warn ( "! Database migration check" ) ;
85- const __filename = fileURLToPath ( import . meta. url ) ;
86- const __dirname = path . dirname ( __filename ) ;
83+
84+ // In dev: this file is at src/common/mongo.ts → ../../migrations
85+ // In prod: code is bundled to dist/main.js → ../migrations
86+ // Detect based on whether we're running from dist/ or src/
87+ const currentFileUrl = new URL ( import . meta. url ) ;
88+ const migrationsDir = currentFileUrl . pathname . includes ( "/dist/" )
89+ ? new URL ( "../migrations" , import . meta. url ) . pathname
90+ : new URL ( "../../migrations" , import . meta. url ) . pathname ;
8791
8892 migrateMongo . config . set ( {
8993 mongodb : {
9094 url : uri ,
9195 databaseName : database ,
9296 } ,
93- migrationsDir : path . join ( __dirname , "../../migrations" ) ,
97+ migrationsDir,
9498 changelogCollectionName : "_migrations" ,
9599 migrationFileExtension : ".mjs" ,
96100 useFileHash : true ,
You can’t perform that action at this time.
0 commit comments