1
0

migration.ts 731 B

123456789101112131415161718192021222324252627
  1. import { generateMigration, revertLastMigration, runMigrations } from '@vendure/core';
  2. import { program } from 'commander';
  3. import { devConfig } from './dev-config';
  4. program
  5. .command('generate <name>')
  6. .description('Generate a new migration file with the given name')
  7. .action(async name => {
  8. await generateMigration(devConfig, { name, outputDir: './migrations' });
  9. });
  10. program
  11. .command('run')
  12. .description('Run all pending migrations')
  13. .action(() => {
  14. return runMigrations(devConfig);
  15. });
  16. program
  17. .command('revert')
  18. .description('Revert the last applied migration')
  19. .action(() => {
  20. return revertLastMigration(devConfig);
  21. });
  22. program.parse(process.argv);