feat: Convert old TS migration names to JS names
This commit is contained in:
26
packages/backend/bin/database/convert-migrations.js
Normal file
26
packages/backend/bin/database/convert-migrations.js
Normal file
@@ -0,0 +1,26 @@
|
||||
import appConfig from '../../src/config/app.js';
|
||||
import logger from '../../src/helpers/logger.js';
|
||||
import '../../src/config/orm.js';
|
||||
import { client as knex } from '../../src/config/database.js';
|
||||
|
||||
export const renameMigrationsAsJsFiles = async () => {
|
||||
if (!appConfig.isDev) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
await knex.raw(
|
||||
`UPDATE knex_migrations SET name = REPLACE(name, '.ts', '.js') WHERE name LIKE '%.ts';`
|
||||
);
|
||||
|
||||
logger.info(
|
||||
`Migration file names with typescript renamed as JS file names!`
|
||||
);
|
||||
} catch (err) {
|
||||
logger.error(err.message);
|
||||
}
|
||||
|
||||
await knex.destroy();
|
||||
};
|
||||
|
||||
renameMigrationsAsJsFiles();
|
@@ -17,7 +17,7 @@
|
||||
"db:drop": "node ./bin/database/drop.js",
|
||||
"db:migration:create": "knex migrate:make",
|
||||
"db:rollback": "knex migrate:rollback",
|
||||
"db:migrate": "knex migrate:latest"
|
||||
"db:migrate": "node ./bin/database/convert-migrations.js && knex migrate:latest"
|
||||
},
|
||||
"dependencies": {
|
||||
"@bull-board/express": "^3.10.1",
|
||||
|
Reference in New Issue
Block a user