tweaked automigrate to check for git status and extracted the base flags from the plugins

This commit is contained in:
Gani Georgiev
2022-11-26 22:33:27 +02:00
parent 8c9b657132
commit 675d459137
11 changed files with 170 additions and 367 deletions
+10 -4
View File
@@ -115,8 +115,11 @@ func (r *Runner) Up() ([]string, error) {
continue
}
if err := m.Up(tx); err != nil {
return fmt.Errorf("Failed to apply migration %s: %w", m.File, err)
// ignore empty Up action
if m.Up != nil {
if err := m.Up(tx); err != nil {
return fmt.Errorf("Failed to apply migration %s: %w", m.File, err)
}
}
if err := r.saveAppliedMigration(tx, m.File); err != nil {
@@ -155,8 +158,11 @@ func (r *Runner) Down(toRevertCount int) ([]string, error) {
break
}
if err := m.Down(tx); err != nil {
return fmt.Errorf("Failed to revert migration %s: %w", m.File, err)
// ignore empty Down action
if m.Down != nil {
if err := m.Down(tx); err != nil {
return fmt.Errorf("Failed to revert migration %s: %w", m.File, err)
}
}
if err := r.saveRevertedMigration(tx, m.File); err != nil {