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
Copy file name to clipboardExpand all lines: .github/ISSUE_TEMPLATE/feature_request.md
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,7 +8,7 @@ assignees: ''
8
8
---
9
9
10
10
### Describe the feature
11
-
[//]: # Provide a thorough description of the feature. If possible, include examples of the feature and its behavior. For example, if it's a new command flag, provide examples of using the command flag and expected outputs.
11
+
<!--Provide a thorough description of the feature. If possible, include examples of the feature and its behavior. For example, if it's a new command flag, provide examples of using the command flag and expected outputs.-->
12
12
13
13
### Motivation
14
-
[//]: # Describe why you want this feature. This is important for assessing the priority of the feature and if alternative solutions exist.
14
+
<!--Describe why you want this feature. This is important for assessing the priority of the feature and if alternative solutions exist.-->
Copy file name to clipboardExpand all lines: README.md
+55-28Lines changed: 55 additions & 28 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -29,19 +29,28 @@ index cc3a14b..cf4b32d 100644
29
29
The generated plan (*queries using `message_idx` will always have an index backing them, even while the new index is being built*):
30
30
```
31
31
$ pg-schema-diff plan --from-dsn "postgres://postgres:postgres@localhost:5432/postgres" --to-dir ./schema
32
-
################################ Generated plan ################################
33
-
1. ALTER INDEX "message_idx" RENAME TO "pgschemadiff_tmpidx_message_idx_IiaKzkvPQtyA7ob9piVqiQ";
34
-
-- Statement Timeout: 3s
35
-
36
-
2. CREATE INDEX CONCURRENTLY message_idx ON public.foobar USING btree (message, created_at);
37
-
-- Statement Timeout: 20m0s
38
-
-- Lock Timeout: 3s
39
-
-- Hazard INDEX_BUILD: This might affect database performance. Concurrent index builds require a non-trivial amount of CPU, potentially affecting database performance. They also can take a while but do not lock out writes.
40
-
41
-
3. DROP INDEX CONCURRENTLY "pgschemadiff_tmpidx_message_idx_IiaKzkvPQtyA7ob9piVqiQ";
42
-
-- Statement Timeout: 20m0s
43
-
-- Lock Timeout: 3s
44
-
-- Hazard INDEX_DROPPED: Dropping this index means queries that use this index might perform worse because they will no longer will be able to leverage it.
32
+
/*
33
+
Statement 0
34
+
*/
35
+
SET SESSION statement_timeout = 3000;
36
+
SET SESSION lock_timeout = 3000;
37
+
ALTER INDEX "public"."message_idx" RENAME TO "pgschemadiff_tmpidx_message_idx_cWw18w4cQ_i7MKzfy7ek9g";
38
+
39
+
/*
40
+
Statement 1
41
+
- INDEX_BUILD: This might affect database performance. Concurrent index builds require a non-trivial amount of CPU, potentially affecting database performance. They also can take a while but do not lock out writes.
42
+
*/
43
+
SET SESSION statement_timeout = 1200000;
44
+
SET SESSION lock_timeout = 3000;
45
+
CREATE INDEX CONCURRENTLY message_idx ON public.foobar USING btree (message, created_at);
46
+
47
+
/*
48
+
Statement 2
49
+
- INDEX_DROPPED: Dropping this index means queries that use this index might perform worse because they will no longer will be able to leverage it.
50
+
*/
51
+
SET SESSION statement_timeout = 1200000;
52
+
SET SESSION lock_timeout = 3000;
53
+
DROP INDEX CONCURRENTLY "public"."pgschemadiff_tmpidx_message_idx_cWw18w4cQ_i7MKzfy7ek9g";
45
54
```
46
55
### Online `NOT NULL` constraint creation
47
56
Your project's diff:
@@ -61,18 +70,33 @@ index cc3a14b..5a1cec2 100644
61
70
The generated plan (*leverages check constraints to eliminate the need for a long-lived access-exclusive lock on the table*):
62
71
```
63
72
$ pg-schema-diff plan --from-dsn "postgres://postgres:postgres@localhost:5432/postgres" --to-dir ./schema
64
-
################################ Generated plan ################################
65
-
1. ALTER TABLE "public"."foobar" ADD CONSTRAINT "pgschemadiff_tmpnn_BCOxMXqAQwaXlKPCRXoMMg" CHECK("created_at" IS NOT NULL) NOT VALID;
66
-
-- Statement Timeout: 3s
67
-
68
-
2. ALTER TABLE "public"."foobar" VALIDATE CONSTRAINT "pgschemadiff_tmpnn_BCOxMXqAQwaXlKPCRXoMMg";
69
-
-- Statement Timeout: 3s
70
-
71
-
3. ALTER TABLE "public"."foobar" ALTER COLUMN "created_at" SET NOT NULL;
72
-
-- Statement Timeout: 3s
73
-
74
-
4. ALTER TABLE "public"."foobar" DROP CONSTRAINT "pgschemadiff_tmpnn_BCOxMXqAQwaXlKPCRXoMMg";
75
-
-- Statement Timeout: 3s
73
+
/*
74
+
Statement 0
75
+
*/
76
+
SET SESSION statement_timeout = 3000;
77
+
SET SESSION lock_timeout = 3000;
78
+
ALTER TABLE "public"."foobar" ADD CONSTRAINT "pgschemadiff_tmpnn_GimngG1rRkODhKvgjhGfNA" CHECK("created_at" IS NOT NULL) NOT VALID;
79
+
80
+
/*
81
+
Statement 1
82
+
*/
83
+
SET SESSION statement_timeout = 3000;
84
+
SET SESSION lock_timeout = 3000;
85
+
ALTER TABLE "public"."foobar" VALIDATE CONSTRAINT "pgschemadiff_tmpnn_GimngG1rRkODhKvgjhGfNA";
86
+
87
+
/*
88
+
Statement 2
89
+
*/
90
+
SET SESSION statement_timeout = 3000;
91
+
SET SESSION lock_timeout = 3000;
92
+
ALTER TABLE "public"."foobar" ALTER COLUMN "created_at" SET NOT NULL;
93
+
94
+
/*
95
+
Statement 3
96
+
*/
97
+
SET SESSION statement_timeout = 3000;
98
+
SET SESSION lock_timeout = 3000;
99
+
ALTER TABLE "public"."foobar" DROP CONSTRAINT "pgschemadiff_tmpnn_GimngG1rRkODhKvgjhGfNA";
76
100
```
77
101
78
102
# Key features
@@ -90,10 +114,14 @@ $ pg-schema-diff plan --from-dsn "postgres://postgres:postgres@localhost:5432/po
90
114
* Strong support of partitions
91
115
# Install
92
116
## CLI
117
+
Brew:
118
+
```bash
119
+
brew install pg-schema-diff
120
+
```
121
+
Go toolchain:
93
122
```bash
94
123
go install github.com/stripe/pg-schema-diff/cmd/pg-schema-diff@latest
95
124
```
96
-
97
125
## Library
98
126
```bash
99
127
go get -u github.com/stripe/pg-schema-diff@latest
@@ -171,12 +199,11 @@ for _, stmt := range plan.Statements {
171
199
```
172
200
173
201
# Supported Postgres versions
174
-
Supported: 14, 15, 16, 17
202
+
Supported: 14, 15, 16, 17
175
203
Unsupported: <= 13 are not supported. Use at your own risk.
176
204
177
205
# Unsupported migrations
178
206
An abridged list of unsupported migrations:
179
-
- Views (Planned)
180
207
- Privileges (Planned)
181
208
- Types (Only enums are currently supported)
182
209
- Renaming. The diffing library relies on names to identify the old and new versions of a table, index, etc. If you rename
tempDbConnFlags:=createConnectionFlags(cmd, "temp-db-", "The temporary database to use for schema extraction. This is optional if diffing to/from a Postgres instance")
44
44
planOptsFlags:=createPlanOptionsFlags(cmd)
45
-
outputFmt:=outputFormatPretty
45
+
outputFmt:=outputFormatSql
46
46
cmd.Flags().Var(
47
47
&outputFmt,
48
48
"output-format",
49
-
fmt.Sprintf("Change the output format for what is printed. Defaults to pretty-printed human-readable output. (options: %s)", strings.Join(outputFormatStrings(), ", ")),
49
+
fmt.Sprintf("Change the output format for what is printed. Defaults to %v. (options: %s)", outputFmt.identifier, strings.Join(outputFormatStrings(), ", ")),
0 commit comments