Describe the bug
I am trying to setup programmatic migrations in my dockerized app. However the migration file resolution is failing.
This is the structure of my container with app being the working directory
|
|- app/
|--- index.js
|--- migrations/
|----------migration_file.js
My migrate call looks like this:
await migrate({
databaseUrl: dbConfig.connectionString,
dir: "migrations",
direction: "up",
migrationsTable: "pgmigrations",
count: Infinity,
log: console.log,
});
The error I get is
2024-06-03 15:28:02 Error: Can't get migration files: Error: Cannot find module 'migrations/1715943927386_init-schema.js'
It seems like the directory is found, but the call to require fails. I have been trying different things for hours, but can not get it to work.
Steps to reproduce
Clone the repo
git clone -b migrations https://github.com/cashubtc/npubcash-server.git
run with
docker compose up
Logs
2024-06-03 15:28:02 Error: Can't get migration files: Error: Cannot find module 'migrations/1715943927386_init-schema.js'
2024-06-03 15:28:02 Require stack:
2024-06-03 15:28:02 - /app/index.js
2024-06-03 15:28:02 at Module._resolveFilename (node:internal/modules/cjs/loader:1140:15)
2024-06-03 15:28:02 Database Migrations failed!!
2024-06-03 15:28:02 at Module._load (node:internal/modules/cjs/loader:981:27)
2024-06-03 15:28:02 at Module.require (node:internal/modules/cjs/loader:1231:19)
2024-06-03 15:28:02 at require (node:internal/modules/helpers:177:18)
2024-06-03 15:28:02 at /app/index.js:77686:118
2024-06-03 15:28:02 at Array.map ()
2024-06-03 15:28:02 at loadMigrations (/app/index.js:77684:13)
2024-06-03 15:28:02 at async Promise.all (index 0)
2024-06-03 15:28:02 at async runner (/app/index.js:77870:36)
2024-06-03 15:28:02 at async setupDatabase (/app/index.js:77929:3)
2024-06-03 15:28:02 at loadMigrations (/app/index.js:77708:11)
2024-06-03 15:28:02 at async Promise.all (index 0)
2024-06-03 15:28:02 at async runner (/app/index.js:77870:36)
2024-06-03 15:28:02 at async setupDatabase (/app/index.js:77929:3)
2024-06-03 15:28:02 at async startServer (/app/index.js:78774:5)
System Info
System:
OS: macOS 14.4.1
CPU: (8) arm64 Apple M2
Memory: 121.73 MB / 8.00 GB
Shell: 5.9 - /bin/zsh
Binaries:
Node: 21.7.2 - /opt/homebrew/bin/node
Yarn: 1.22.22 - /opt/homebrew/bin/yarn
npm: 10.5.0 - /opt/homebrew/bin/npm
bun: 1.1.3 - /opt/homebrew/bin/bun
Used Module System
esm
Describe the bug
I am trying to setup programmatic migrations in my dockerized app. However the migration file resolution is failing.
This is the structure of my container with app being the working directory
|
|- app/
|--- index.js
|--- migrations/
|----------migration_file.js
My migrate call looks like this:
The error I get is
2024-06-03 15:28:02 Error: Can't get migration files: Error: Cannot find module 'migrations/1715943927386_init-schema.js'It seems like the directory is found, but the call to require fails. I have been trying different things for hours, but can not get it to work.
Steps to reproduce
Clone the repo
git clone -b migrations https://github.com/cashubtc/npubcash-server.gitrun with
docker compose upLogs
2024-06-03 15:28:02 Error: Can't get migration files: Error: Cannot find module 'migrations/1715943927386_init-schema.js'
2024-06-03 15:28:02 Require stack:
2024-06-03 15:28:02 - /app/index.js
2024-06-03 15:28:02 at Module._resolveFilename (node:internal/modules/cjs/loader:1140:15)
2024-06-03 15:28:02 Database Migrations failed!!
2024-06-03 15:28:02 at Module._load (node:internal/modules/cjs/loader:981:27)
2024-06-03 15:28:02 at Module.require (node:internal/modules/cjs/loader:1231:19)
2024-06-03 15:28:02 at require (node:internal/modules/helpers:177:18)
2024-06-03 15:28:02 at /app/index.js:77686:118
2024-06-03 15:28:02 at Array.map ()
2024-06-03 15:28:02 at loadMigrations (/app/index.js:77684:13)
2024-06-03 15:28:02 at async Promise.all (index 0)
2024-06-03 15:28:02 at async runner (/app/index.js:77870:36)
2024-06-03 15:28:02 at async setupDatabase (/app/index.js:77929:3)
2024-06-03 15:28:02 at loadMigrations (/app/index.js:77708:11)
2024-06-03 15:28:02 at async Promise.all (index 0)
2024-06-03 15:28:02 at async runner (/app/index.js:77870:36)
2024-06-03 15:28:02 at async setupDatabase (/app/index.js:77929:3)
2024-06-03 15:28:02 at async startServer (/app/index.js:78774:5)
System Info
System: OS: macOS 14.4.1 CPU: (8) arm64 Apple M2 Memory: 121.73 MB / 8.00 GB Shell: 5.9 - /bin/zsh Binaries: Node: 21.7.2 - /opt/homebrew/bin/node Yarn: 1.22.22 - /opt/homebrew/bin/yarn npm: 10.5.0 - /opt/homebrew/bin/npm bun: 1.1.3 - /opt/homebrew/bin/bunUsed Module System
esm