Skip to content

Commit 1e4ed72

Browse files
Update docs for new versionSchema field (#887)
Update documentation for the new `versionSchema` field and add an example migration. --- This PR is part of a stack: * #884 * #886 * #887 (this PR)
1 parent 050e2ea commit 1e4ed72

File tree

6 files changed

+26
-0
lines changed

6 files changed

+26
-0
lines changed

docs/operations/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,17 @@
55
YAML migration:
66

77
```yaml
8+
version_schema: <version schema name>
89
operations: [...]
910
```
1011
1112
JSON migration:
1213
1314
```json
1415
{
16+
"version_schema": "<version schema name>",
1517
"operations": [...]
1618
}
1719
```
1820

21+
The `version_schema` field is optional and specifies the name of the schema that will be created for the migration. If not specified, the name of the migration file (minus any `.yaml` or `.json` suffix) will be used as the schema name.

docs/operations/create_table.mdx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,3 +231,7 @@ Create a table with table level foreign key constraints:
231231
Create a table with an exclusion:
232232

233233
<ExampleSnippet example="52_create_table_with_exclusion_constraint.yaml" languange="yaml" />
234+
235+
### Create a table and set the version_schema field for the migration
236+
237+
<ExampleSnippet example="56_with_version_schema.yaml" languange="yaml" />

examples/.ledger

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,3 +53,4 @@
5353
53_add_column_with_volatile_default.yaml
5454
54_create_index_with_opclass.yaml
5555
55_add_primary_key_constraint_to_table.yaml
56+
56_with_version_schema.yaml

examples/56_with_version_schema.yaml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
version_schema: with_version_schema
2+
operations:
3+
- create_table:
4+
name: products
5+
columns:
6+
- name: id
7+
type: serial
8+
pk: true
9+
- name: name
10+
type: varchar(255)
11+
unique: true

pkg/migrations/types.go

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

schema.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1162,6 +1162,10 @@
11621162
"description": "Name of the migration",
11631163
"type": "string"
11641164
},
1165+
"version_schema": {
1166+
"description": "Name of the version schema to use for this migration",
1167+
"type": "string"
1168+
},
11651169
"operations": {
11661170
"$ref": "#/$defs/PgRollOperations"
11671171
}

0 commit comments

Comments
 (0)