-
Notifications
You must be signed in to change notification settings - Fork 92
Use sql2pgroll.Convert
in convert
command to translate SQL statements from migration file and stdin
#695
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…ents from migration file and stdin
49e93f5
to
fd8a6e6
Compare
cmd/convert.go
Outdated
}, | ||
} | ||
|
||
convertCmd.Flags().StringVar(&migrationName, "migration-name", "{current_timestamp}", "Name of the migration") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this flag should be called name
rather than migration-name
. It should also have a short form of -n
(use StringVarP
).
cmd/convert.go
Outdated
@@ -24,11 +32,24 @@ func convertCmd() *cobra.Command { | |||
} | |||
defer reader.Close() | |||
|
|||
_, err = scanSQLStatements(reader) | |||
return err | |||
if migrationName == "" { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This check doesn't work as expected because the flag definition assigns the string "{current_timestamp}"
to migrationName
if it isn't supplied by the user.
Co-authored-by: Andrew Farries <andyrb@gmail.com>
Co-authored-by: Andrew Farries <andyrb@gmail.com>
This PR adds the implementation to the subcommand
convert
. From now on,pgroll convert
can translate several SQL migrations into a single migration file.It has one flag called
name
so users can specify a name for their migration.If they don't,
pgroll
sets the name to the current timestamp.The command expects input either from an SQL migration file or stdin.
I am adding more detailed documentation when we expose the command publicly.