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