Skip to content

Commit

Permalink
Chore: Add migration start message with schema name (#384)
Browse files Browse the repository at this point in the history
Hi, I noticed an issue that seemed like a quick fix, so I went ahead and
made the changes.
The related issue is here: 
- #368

In this PR, I made changes to prioritize using the `name` property in
migration file. If `name` is empty, we fall back to using the filename.

I'd appreciate it if you could take a look when you have some time.
  • Loading branch information
t-ham752 authored Aug 26, 2024
1 parent 3f792b7 commit bec15d8
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions cmd/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func startCmd() *cobra.Command {
}
defer m.Close()

file, err := os.Open(args[0])
file, err := os.Open(fileName)
if err != nil {
return fmt.Errorf("opening migration file: %w", err)
}
Expand Down Expand Up @@ -61,7 +61,10 @@ func startCmd() *cobra.Command {
}
}

version := strings.TrimSuffix(filepath.Base(fileName), filepath.Ext(fileName))
version := migration.Name
if version == "" {
version = strings.TrimSuffix(filepath.Base(fileName), filepath.Ext(fileName))
}
viewName := roll.VersionedSchemaName(flags.Schema(), version)
msg := fmt.Sprintf("New version of the schema available under the postgres %q schema", viewName)
sp.Success(msg)
Expand Down

0 comments on commit bec15d8

Please sign in to comment.