Skip to content

Commit bd6134d

Browse files
kvchandrew-farries
andauthored
Publish convert command and add new documentation page (#700)
This PR publishes the new subcommand `convert`, and adds a new documentation page. This must be merged before the v0.10.0 release. --------- Co-authored-by: Andrew Farries <andyrb@gmail.com>
1 parent 7b383dc commit bd6134d

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

cmd/convert.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ func convertCmd() *cobra.Command {
2424
Long: "Convert SQL statements to a pgroll migration. The command can read SQL statements from stdin or a file",
2525
Args: cobra.MaximumNArgs(1),
2626
ValidArgs: []string{"migration-file"},
27-
Hidden: true,
2827
RunE: func(cmd *cobra.Command, args []string) error {
2928
reader, err := openSQLReader(args)
3029
if err != nil {

docs/cli/convert.mdx

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
---
2+
title: Convert
3+
description: Convert SQL migration files to a pgroll migration
4+
---
5+
6+
## Command
7+
8+
```
9+
$ pgroll convert --name 01_create_first_table /path/to/migration.sql
10+
```
11+
12+
This reads the SQL statements from `/path/to/migration.sql` and translates them into a `pgroll` migration. The name of the migration will be `01_create_first_table`.
13+
14+
### Read SQL statements from stdin
15+
16+
If a file name is not specified `pgroll convert` reads the SQL statements from stdin.
17+
18+
```
19+
$ cat 'CREATE TABLE my_table(name text);' | pgroll convert --name 01_create_first_table
20+
```
21+
22+
<Warning>
23+
The generated pgroll migrations might include `up` and `down` migrations. Those must be filled in manually because currently `pgroll` is unable to infer correct up and down migrations.
24+
</Warning>

0 commit comments

Comments
 (0)