diff --git a/packages/backend/bin/database/convert-migrations.js b/packages/backend/bin/database/convert-migrations.js index e7d0243a..8334edc5 100644 --- a/packages/backend/bin/database/convert-migrations.js +++ b/packages/backend/bin/database/convert-migrations.js @@ -9,13 +9,18 @@ export const renameMigrationsAsJsFiles = async () => { } try { - await knex.raw( - `UPDATE knex_migrations SET name = REPLACE(name, '.ts', '.js') WHERE name LIKE '%.ts';` - ); + const tableExists = await knex.schema.hasTable('knex_migrations'); - logger.info( - `Migration file names with typescript renamed as JS file names!` - ); + if (tableExists) { + 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) { logger.error(err.message); } diff --git a/packages/backend/bin/database/utils.js b/packages/backend/bin/database/utils.js index 5e79c05d..4d373353 100644 --- a/packages/backend/bin/database/utils.js +++ b/packages/backend/bin/database/utils.js @@ -4,6 +4,7 @@ import client from './client.js'; import User from '../../src/models/user.js'; import Role from '../../src/models/role.js'; import '../../src/config/orm.js'; +import process from 'process'; async function fetchAdminRole() { const role = await Role.query() @@ -46,6 +47,8 @@ export async function createUser( logger.info(`User already exists: ${email}`); } + + process.exit(0); } export const createDatabaseAndUser = async ( @@ -58,6 +61,7 @@ export const createDatabaseAndUser = async ( await grantPrivileges(database, user); await client.end(); + process.exit(0); }; export const createDatabase = async (database = appConfig.postgresDatabase) => {