From bec15d8ce9666bf9ae95ab298cbf28094b126f5c Mon Sep 17 00:00:00 2001 From: Taiga Hamoro <84676230+t-ham752@users.noreply.github.com> Date: Mon, 26 Aug 2024 18:59:04 +0900 Subject: [PATCH] Chore: Add migration start message with schema name (#384) Hi, I noticed an issue that seemed like a quick fix, so I went ahead and made the changes. The related issue is here: - https://github.com/xataio/pgroll/issues/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. --- cmd/start.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/cmd/start.go b/cmd/start.go index 7643bb7b..9e3a142d 100644 --- a/cmd/start.go +++ b/cmd/start.go @@ -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) } @@ -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)