Skip to content

Commit c98be9a

Browse files
committed
feat: schema-first workflow configuration
1 parent d74eb7a commit c98be9a

3 files changed

Lines changed: 16 additions & 6 deletions

File tree

cmd/snapshot.go

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -379,10 +379,12 @@ func runSnapshotBuild() error {
379379
return fmt.Errorf("pguri not configured in regress.yaml")
380380
}
381381

382-
// Resolve and validate schema path
383-
var schemaPath string
384-
if snapshotBuildSchema != "" {
385-
schemaPath = snapshotBuildSchema
382+
// Use config values as defaults when flags not provided
383+
schemaPath := snapshotBuildSchema
384+
if schemaPath == "" {
385+
schemaPath = regresql.GetSnapshotSchema(cfg.Snapshot)
386+
}
387+
if schemaPath != "" {
386388
if !filepath.IsAbs(schemaPath) {
387389
schemaPath = filepath.Join(snapshotCwd, schemaPath)
388390
}
@@ -396,9 +398,9 @@ func runSnapshotBuild() error {
396398
fixtures = regresql.GetSnapshotFixtures(cfg.Snapshot)
397399
}
398400

399-
// Allow build with just schema (no fixtures)
401+
// Require at least schema or fixtures
400402
if len(fixtures) == 0 && schemaPath == "" {
401-
return fmt.Errorf("no fixtures specified. Use --fixtures flag or configure snapshot.fixtures in regress.yaml")
403+
return fmt.Errorf("no schema or fixtures specified. Use --schema/--fixtures flags or configure snapshot.schema/snapshot.fixtures in regress.yaml")
402404
}
403405

404406
if len(fixtures) > 0 {

regresql/config.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ type (
3030
SnapshotConfig struct {
3131
Path string `yaml:"path,omitempty"` // snapshot dump file path (default: snapshots/default.dump)
3232
Format string `yaml:"format,omitempty"` // pg_dump format: custom, plain, or directory
33+
Schema string `yaml:"schema,omitempty"` // external schema file (SQL, dump, or directory)
3334
Fixtures []string `yaml:"fixtures,omitempty"` // SQL/YAML fixture files for snapshot build
3435
}
3536
)

regresql/snapshot_build.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,13 @@ func GetSnapshotFixtures(cfg *SnapshotConfig) []string {
230230
return cfg.Fixtures
231231
}
232232

233+
func GetSnapshotSchema(cfg *SnapshotConfig) string {
234+
if cfg == nil {
235+
return ""
236+
}
237+
return cfg.Schema
238+
}
239+
233240
// FixturesExist validates that all fixture files exist before build.
234241
func FixturesExist(root string, fixtures []string) error {
235242
for _, f := range fixtures {

0 commit comments

Comments
 (0)