File size: 652 Bytes
3206347
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import './check-env-file.js';
import { createDatabaseAndUser } from '../../bin/database/utils.js';
import { client as knex } from '../../src/config/database.js';
import logger from '../../src/helpers/logger.js';
import appConfig from '../../src/config/app.js';

const createAndMigrateDatabase = async () => {
  if (!appConfig.CI) {
    await createDatabaseAndUser();
  }

  const migrator = knex.migrate;

  await migrator.latest();

  logger.info(`Completed database migrations for the test database.`);
};

createAndMigrateDatabase()
  .then(() => {
    process.exit(0);
  })
  .catch((error) => {
    logger.error(error);
    process.exit(1);
  });