redwood: [Bug?]: rw data-migration looks for src folder

What’s not working?

I’m trying to run rw data-migration from our CI after copying the files over to the docker container.

It complains about the files not being in /app/api/src/lib/db, which is correct. As I copied them to /app/api/db and would like to keep it like that, as that’s the git path and similar to the schema migrations.

rw data-migrate up

Run any outstanding Data Migrations against the database

Options:
  --help     Show help                                                 [boolean]
  --version  Show version number                                       [boolean]
  --cwd      Working directory to use (where `redwood.toml` is located)

Also see the Redwood CLI Reference
(​https://redwoodjs.com/docs/cli-commands#datamigrate-up​)

Error: Cannot find module '/app/api/src/lib/db'
Require stack:
- /usr/local/share/.config/yarn/global/node_modules/@redwoodjs/cli/dist/commands/dataMigrate/up.js
- /usr/local/share/.config/yarn/global/node_modules/yargs/build/index.cjs
- /usr/local/share/.config/yarn/global/node_modules/yargs/helpers/index.js
- /usr/local/share/.config/yarn/global/node_modules/@redwoodjs/cli/dist/index.js
    at Function.Module._resolveFilename (node:internal/modules/cjs/loader:1026:15)
    at Function.Module._load (node:internal/modules/cjs/loader:871:27)
    at Module.require (node:internal/modules/cjs/loader:1098:19)
    at require (node:internal/modules/cjs/helpers:108:18)
    at Object.handler (/usr/local/share/.config/yarn/global/node_modules/@redwoodjs/cli/dist/commands/dataMigrate/up.js:126:7)
    at /usr/local/share/.config/yarn/global/node_modules/yargs/build/index.cjs:1:8993
    at /usr/local/share/.config/yarn/global/node_modules/yargs/build/index.cjs:1:4949
    at processTicksAndRejections (node:internal/process/task_queues:96:5) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    '/usr/local/share/.config/yarn/global/node_modules/@redwoodjs/cli/dist/commands/dataMigrate/up.js',
    '/usr/local/share/.config/yarn/global/node_modules/yargs/build/index.cjs',
    '/usr/local/share/.config/yarn/global/node_modules/yargs/helpers/index.js',
    '/usr/local/share/.config/yarn/global/node_modules/@redwoodjs/cli/dist/index.js'
  ]
}

How do we reproduce the bug?

Build a docker container with both api and web in one container, like in the examples.

Install redwood like this at some point

RUN yarn --cwd "api" --production install && \
  yarn global add @redwoodjs/cli prisma @sentry/cli

Try to run your data migrations, in my case I added this line rw data-migrate up to my run.sh

What’s your environment? (If it applies)

The affected system is a docker container with node 16 on alipne 3.16

Are you interested in working on this?

  • I’m interested in working on this

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Comments: 15 (15 by maintainers)

Most upvoted comments

@thedavidprice it sounds similar but I don’t remember the exact package, I still haven’t looked into, will try to do that today. The similarity between this issue and that issue is missing packages, but they’re missing in this issue because we’re in a Dockerized environment where we’re deliberately trying to remove packages to make a small image. The case you saw may just be a mistake on our part, but again I need to look into it.

@razzeee here’s what I think is going on… the yarn rw data-migrate command depends on @redwoodjs/internal. All the logic for how to build a Redwood project lives in that package. Normally you wouldn’t need that package once you’ve built the framework, but data migration files never get built. They’re still ES6 syntax, so the strategy for running those is still to transpile them on the fly, as they’re imported. So we need @redwoodjs/internal around for that.

But it’s more unfortunate than that… @redwoodjs/internal doesn’t list the packages it needs to run Babel, @redwoodjs/core does. Why? I’m not sure, that was a bit before my time.

Anyway none of that is good news. I’m trying to isolate data migrate as a command here; maybe I can fix the issues in that PR by bundling everything: https://github.com/redwoodjs/redwood/pull/8572

I’ll report back when I’ve actually run this successfully in a Docker container this time

I can copy that easily I guess, I just trimmed the code down as much as before and forgot about the migration folder/thought it might be in the dist. As I copied the whole api folder before.

I don’t think your correct, I did always install this

RUN yarn global add @redwoodjs/cli prisma

and then run rw data-migrate up on container start/entrypoint.

When I was still doing yarn --cwd "api" --production install, it ended up complaining about babel missing