feat: Convert migration file names if there is a table
This commit is contained in:
@@ -9,13 +9,18 @@ export const renameMigrationsAsJsFiles = async () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await knex.raw(
|
const tableExists = await knex.schema.hasTable('knex_migrations');
|
||||||
`UPDATE knex_migrations SET name = REPLACE(name, '.ts', '.js') WHERE name LIKE '%.ts';`
|
|
||||||
);
|
|
||||||
|
|
||||||
logger.info(
|
if (tableExists) {
|
||||||
`Migration file names with typescript renamed as JS file names!`
|
await knex('knex_migrations')
|
||||||
);
|
.where('name', 'like', '%.ts')
|
||||||
|
.update({
|
||||||
|
name: knex.raw("REPLACE(name, '.ts', '.js')"),
|
||||||
|
});
|
||||||
|
logger.info(
|
||||||
|
`Migration file names with typescript renamed as JS file names!`
|
||||||
|
);
|
||||||
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
logger.error(err.message);
|
logger.error(err.message);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user