Skip to content

Commit

Permalink
Check filenames for func migrations. (#32)
Browse files Browse the repository at this point in the history
  • Loading branch information
lmalmen authored Jun 28, 2023
1 parent 6d163bd commit da6d853
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions migration.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,14 @@ func (s *Service) Migrate() error {
if err != nil {
return fmt.Errorf("failed to get checksum for file %s: %w", mig, err)
}

if strings.HasSuffix(mig, ".go") {
c, err = s.checksum(bytes.NewReader([]byte(mig)))
if err != nil {
return fmt.Errorf("failed to create checksum for migration: %w", err)
}
}

if c != chkSum {
return fmt.Errorf("file %s has been updated since it was migrated", mig)
}
Expand Down

0 comments on commit da6d853

Please sign in to comment.