Merge pull request #2033 from balena-os/knex-bug-2032

Fix migrations hardcode to work with knex 0.95.15
This commit is contained in:
bulldozer-balena[bot] 2022-09-28 00:19:49 +00:00 committed by GitHub
commit 4863303270
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 7 deletions

View File

@ -2,10 +2,12 @@
// This hack makes the migrations directory a constant so that at least we can use webpack contexts for the // This hack makes the migrations directory a constant so that at least we can use webpack contexts for the
// require. // require.
module.exports = function (source) { module.exports = function (source) {
return source return (
.toString() source
.replace( .toString()
'path.join(absoluteDir, migration.file)', // IMPORTANT: this is known to work with knex v0.95.15. It will most likely break
`'./migrations/'+migration.file`, // if knex is upgraded. This is really a hack and should be replaced by a more sustainable
); // webpack configuration.
.replace('importFile(_path)', "require('./migrations/'+migration.file)")
);
}; };

View File

@ -103,7 +103,10 @@ module.exports = function (env) {
{ {
include: [ include: [
new RegExp( new RegExp(
_.escapeRegExp(path.join('knex', 'lib', 'migrate', 'sources')), _.escapeRegExp(
// this is the path as of knex@0.95.15
path.join('knex', 'lib', 'migrations', 'migrate', 'sources'),
),
), ),
], ],
use: require.resolve('./build-utils/hardcode-migrations'), use: require.resolve('./build-utils/hardcode-migrations'),