// Copyright IBM Corp. and LoopBack contributors 2019. All Rights Reserved. // Node module: @loopback/example-express-composition // This file is licensed under the MIT License. // License text available at https://opensource.org/licenses/MIT import {ExpressServer} from './server'; export async function migrate(args: string[]) { const existingSchema = args.includes('--rebuild') ? 'drop' : 'alter'; console.log('Migrating schemas (%s existing schema)', existingSchema); const server = new ExpressServer(); await server.boot(); await server.lbApp.migrateSchema({existingSchema}); // Connectors usually keep a pool of opened connections, // this keeps the process running even after all work is done. // We need to exit explicitly. process.exit(0); } migrate(process.argv).catch(err => { console.error('Cannot migrate database schema', err); process.exit(1); });