28 lines
1.1 KiB
TypeScript
28 lines
1.1 KiB
TypeScript
import { execSync } from 'child_process';
|
|
|
|
const migrationName = process.argv[2];
|
|
|
|
if (!migrationName) {
|
|
console.error('Please provide a migration name: npm run migration:full <migration_name>');
|
|
process.exit(1);
|
|
}
|
|
|
|
try {
|
|
console.log(`Creating migration: ${migrationName}`);
|
|
execSync(`npx ts-node -r tsconfig-paths/register ./node_modules/typeorm/cli migration:create ./src/Infrastructure/Migrationsettings/${migrationName}`, { stdio: 'inherit' });
|
|
|
|
console.log(`Generating migration: ${migrationName}`);
|
|
execSync(`npx ts-node -r tsconfig-paths/register ./node_modules/typeorm/cli -d ./src/Infrastructure/ormconfig.ts migration:generate ./src/Infrastructure/Migrations/${migrationName}`, { stdio: 'inherit' });
|
|
|
|
console.log('Migration generated successfully!');
|
|
|
|
console.log('Running migration...');
|
|
execSync(`npx ts-node -r tsconfig-paths/register ./node_modules/typeorm/cli -d ./src/Infrastructure/ormconfig.ts migration:run`, { stdio: 'inherit' });
|
|
} catch (error) {
|
|
if (error instanceof Error) {
|
|
console.error('Migration failed:', error.message);
|
|
} else {
|
|
console.error('Migration failed:', error);
|
|
}
|
|
process.exit(1);
|
|
} |