Merge pull request #1532 from automatisch/seed-user
fix: Exit process after creating seed user
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
@@ -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) => {
|
||||
|
Reference in New Issue
Block a user