You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Use sql2pgroll.Convert in convert command to translate SQL statements from migration file and stdin (#695)
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 `migration-name` so users can specify a name for
their migration.
If they don't, `pgroll` sets the name to the current timestamp.
```sh
$ pgroll convert --help
Convert SQL statements to pgroll migrations. The command can read SQL statements from stdin or a file
Usage:
pgroll convert <path to file with migrations> [flags]
Flags:
-h, --help help for convert
-n, --name string Name of the migration (default "{current_timestamp}")
```
The command expects input either from an SQL migration file or stdin.
```sh
$ echo "CREATE TABLE t1(); alter table t1 add column name text; create type t1 as enum ('1','2','3')" | pgroll convert
{
"name": "20250220125242",
"operations": [
{
"create_table": {
"columns": null,
"name": "t1"
}
},
{
"add_column": {
"column": {
"name": "name",
"nullable": true,
"type": "text"
},
"table": "t1",
"up": "TODO: Implement SQL data migration"
}
},
{
"sql": {
"up": "create type t1 as enum ('1','2','3')"
}
}
]
}
```
I am adding more detailed documentation when we expose the command
publicly.
---------
Co-authored-by: Andrew Farries <[email protected]>
0 commit comments