UNPKG

@slickteam/nestjs-pg-typeorm

Version:
55 lines (52 loc) 1.83 kB
#!/usr/bin/env node "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const child_process_1 = require("child_process"); const path_1 = require("path"); const args = process.argv.slice(2); const command = args[0]; const restArgs = args.slice(1).join(' '); const dataSourcePath = (0, path_1.resolve)(__dirname, 'database-config.js'); const commands = { create: `typeorm migration:create ${restArgs}`, generate: `typeorm migration:generate -d ${dataSourcePath} ${restArgs}`, run: `typeorm migration:run -d ${dataSourcePath} ${restArgs}`, revert: `typeorm migration:revert -d ${dataSourcePath} ${restArgs}`, show: `typeorm migration:show -d ${dataSourcePath} ${restArgs}`, drop: `typeorm schema:drop -d ${dataSourcePath} ${restArgs}`, }; function printHelp() { console.log(` slick-migration - TypeORM migration CLI for @slickteam/nestjs-pg-typeorm Usage: slick-migration <command> [options] Commands: create <path> Create a new empty migration file generate <path> Generate a migration from schema changes run Run pending migrations revert Revert the last executed migration show Show all migrations and their status drop Drop the database schema Examples: slick-migration create src/migrations/CreateUserTable slick-migration generate src/migrations/AddEmailColumn slick-migration run slick-migration revert slick-migration show `); } if (!command || command === '--help' || command === '-h') { printHelp(); process.exit(0); } if (!commands[command]) { console.error(`Unknown command: ${command}\n`); printHelp(); process.exit(1); } try { (0, child_process_1.execSync)(commands[command], { stdio: 'inherit' }); } catch { process.exit(1); } //# sourceMappingURL=cli.js.map