@@ -11,15 +11,15 @@ import (
1111)
1212
1313var (
14- snapshotCwd string
15- snapshotOutput string
16- snapshotOutputDir string
17- snapshotFormat string
18- snapshotSchemaOnly bool
19- snapshotSection string
20- snapshotSections bool
21- snapshotInput string
22- snapshotClean bool
14+ snapshotCwd string
15+ snapshotOutput string
16+ snapshotOutputDir string
17+ snapshotFormat string
18+ snapshotSchemaOnly bool
19+ snapshotSection string
20+ snapshotSections bool
21+ snapshotInput string
22+ snapshotClean bool
2323 snapshotBuildFixtures []string
2424 snapshotBuildSchema string
2525 snapshotBuildMigrations string
@@ -408,13 +408,20 @@ func runSnapshotBuild() error {
408408 }
409409 }
410410
411+ migrationCommand := regresql .GetSnapshotMigrationCommand (cfg .Snapshot )
412+
413+ // migrations dir and migration_command are mutually exclusive
414+ if migrationsDir != "" && migrationCommand != "" {
415+ return fmt .Errorf ("cannot use both 'migrations' directory and 'migration_command' - choose one" )
416+ }
417+
411418 fixtures := snapshotBuildFixtures
412419 if len (fixtures ) == 0 {
413420 fixtures = regresql .GetSnapshotFixtures (cfg .Snapshot )
414421 }
415422
416- // Require at least schema, migrations, or fixtures
417- if len (fixtures ) == 0 && schemaPath == "" && migrationsDir == "" {
423+ // require at least schema, migrations, migration_command , or fixtures
424+ if len (fixtures ) == 0 && schemaPath == "" && migrationsDir == "" && migrationCommand == "" {
418425 return fmt .Errorf ("no schema, migrations, or fixtures specified. Use flags or configure in regress.yaml" )
419426 }
420427
@@ -448,18 +455,22 @@ func runSnapshotBuild() error {
448455 if migrationsDir != "" {
449456 fmt .Printf (" Migrations: %s\n " , migrationsDir )
450457 }
458+ if migrationCommand != "" {
459+ fmt .Printf (" Migration cmd: %s\n " , migrationCommand )
460+ }
451461 if len (fixtures ) > 0 {
452462 fmt .Printf (" Fixtures: %v\n " , fixtures )
453463 }
454464 fmt .Println ()
455465
456466 result , err := regresql .BuildSnapshot (cfg .PgUri , snapshotCwd , regresql.SnapshotBuildOptions {
457- OutputPath : outputPath ,
458- Format : format ,
459- SchemaPath : schemaPath ,
460- MigrationsDir : migrationsDir ,
461- Fixtures : fixtures ,
462- Verbose : snapshotBuildVerbose ,
467+ OutputPath : outputPath ,
468+ Format : format ,
469+ SchemaPath : schemaPath ,
470+ MigrationsDir : migrationsDir ,
471+ MigrationCommand : migrationCommand ,
472+ Fixtures : fixtures ,
473+ Verbose : snapshotBuildVerbose ,
463474 })
464475 if err != nil {
465476 return err
@@ -480,6 +491,9 @@ func runSnapshotBuild() error {
480491 if len (result .Info .MigrationsApplied ) > 0 {
481492 fmt .Printf (" Migrations: %d applied\n " , len (result .Info .MigrationsApplied ))
482493 }
494+ if result .Info .MigrationCommandHash != "" {
495+ fmt .Printf (" Migration cmd: executed\n " )
496+ }
483497 if len (result .FixturesUsed ) > 0 {
484498 fmt .Printf (" Fixtures: %d applied\n " , len (result .FixturesUsed ))
485499 }
@@ -527,6 +541,13 @@ func runSnapshotInfo() error {
527541 }
528542 }
529543
544+ if info .MigrationCommand != "" {
545+ fmt .Println ()
546+ fmt .Println ("Migration command:" )
547+ fmt .Printf (" Command: %s\n " , info .MigrationCommand )
548+ fmt .Printf (" Hash: %s\n " , info .MigrationCommandHash )
549+ }
550+
530551 if len (info .FixturesUsed ) > 0 {
531552 fmt .Println ()
532553 fmt .Println ("Fixtures used:" )
0 commit comments