import dotenv from 'dotenv' ; import dotenvExt from 'dotenv-extended' ; import { AuditExampleApplication } from './application' ; dotenv . config ( ) ; dotenvExt . load ( { schema : '.env.example' , errorOnMissing : true , includeProcessEnv : true , } ) ; export async function migrate ( args ) { const existingSchema = args . includes ( '--rebuild' ) ? 'drop' : 'alter' ; console . log ( 'Migrating schemas (%s existing schema)' , existingSchema ) ; const app = new AuditExampleApplication ( ) ; await app . boot ( ) ; await app . migrateSchema ( { existingSchema } ) ; process . exit ( 0 ) ; } migrate ( process . argv ) . catch ( err => { console . error ( 'Cannot migrate database schema' , err ) ; process . exit ( 1 ) ; } ) ;