feat(cli): create DB in start command if not exists (#285)
This commit is contained in:
@@ -4,16 +4,14 @@ import type { Knex } from 'knex';
|
||||
import knexConfig from '../../knexfile';
|
||||
import logger from '../helpers/logger';
|
||||
|
||||
const knexInstance: Knex = knex(knexConfig);
|
||||
export const client: Knex = knex(knexConfig);
|
||||
|
||||
const CONNECTION_REFUSED = 'ECONNREFUSED';
|
||||
|
||||
knexInstance.raw('SELECT 1')
|
||||
client.raw('SELECT 1')
|
||||
.catch((err) => {
|
||||
if (err.code === CONNECTION_REFUSED) {
|
||||
logger.error('Make sure you have installed PostgreSQL and it is running.', err);
|
||||
process.exit();
|
||||
}
|
||||
});
|
||||
|
||||
export default knexInstance;
|
||||
|
@@ -1,4 +1,4 @@
|
||||
import { Model } from 'objection';
|
||||
import database from './database';
|
||||
import { client } from './database';
|
||||
|
||||
Model.knex(database)
|
||||
Model.knex(client);
|
||||
|
Reference in New Issue
Block a user