codemods icon indicating copy to clipboard operation
codemods copied to clipboard

Error migrating application with multiple `database.js` files using `env` folder

Open vstollen opened this issue 2 years ago • 1 comments

While migrating my application I got the error:

error: Cannot find module '/[...]/strapi-project/config/database.js'
Require stack:
- /home/<user>/.npm/_npx/636cd3a3cca06392/node_modules/@strapi/codemods/lib/v4/migration-helpers/update-application-folder-structure.js
- /home/<user>/.npm/_npx/636cd3a3cca06392/node_modules/@strapi/codemods/lib/v4/migration-helpers/index.js
- /home/<user>/.npm/_npx/636cd3a3cca06392/node_modules/@strapi/codemods/lib/v4/index.js
- /home/<user>/.npm/_npx/636cd3a3cca06392/node_modules/@strapi/codemods/lib/index.js
- /home/<user>/.npm/_npx/636cd3a3cca06392/node_modules/@strapi/codemods/bin/commands/migrate.js
- /home/<user>/.npm/_npx/636cd3a3cca06392/node_modules/@strapi/codemods/bin/commands/default-commands.js
- /home/<user>/.npm/_npx/636cd3a3cca06392/node_modules/@strapi/codemods/bin/cli.js

I do not have a config/database.js, because I use environments using the env folder: https://docs-v3.strapi.io/developer-docs/latest/setup-deployment-guides/configurations.html#formats

It would be nice, if codemods supported this case gracefully.

Tested using @strapi/[email protected]

vstollen avatar Oct 29 '22 11:10 vstollen

Regardless if you have several database.js files you should always have the root one as we merge keys.

Not having the root database.js is absolutely not recommended and will cause issues.

derrickmehaffy avatar Oct 30 '22 15:10 derrickmehaffy