Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migration file resolution fails inside docker container #1184

Open
Egge21M opened this issue Jun 3, 2024 · 0 comments
Open

Migration file resolution fails inside docker container #1184

Egge21M opened this issue Jun 3, 2024 · 0 comments
Labels
s: pending triage Pending Triage

Comments

@Egge21M
Copy link

Egge21M commented Jun 3, 2024

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

@Egge21M Egge21M added the s: pending triage Pending Triage label Jun 3, 2024
@Egge21M Egge21M closed this as completed Jun 3, 2024
@Egge21M Egge21M reopened this Jun 3, 2024
@Shinigami92 Shinigami92 changed the title Migration file resolution fails Migration file resolution fails inside docker container Jun 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
s: pending triage Pending Triage
Projects
None yet
Development

No branches or pull requests

1 participant