Skip to content

Commit f40bbbe

Browse files
Update readme (#240)
1 parent a7b3d5e commit f40bbbe

File tree

1 file changed

+54
-26
lines changed

1 file changed

+54
-26
lines changed

README.md

Lines changed: 54 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -29,19 +29,28 @@ index cc3a14b..cf4b32d 100644
2929
The generated plan (*queries using `message_idx` will always have an index backing them, even while the new index is being built*):
3030
```
3131
$ 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";
4554
```
4655
### Online `NOT NULL` constraint creation
4756
Your project's diff:
@@ -61,18 +70,33 @@ index cc3a14b..5a1cec2 100644
6170
The generated plan (*leverages check constraints to eliminate the need for a long-lived access-exclusive lock on the table*):
6271
```
6372
$ 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";
76100
```
77101

78102
# Key features
@@ -90,10 +114,14 @@ $ pg-schema-diff plan --from-dsn "postgres://postgres:postgres@localhost:5432/po
90114
* Strong support of partitions
91115
# Install
92116
## CLI
117+
Brew:
118+
```bash
119+
brew install pg-schema-diff
120+
```
121+
Go toolchain:
93122
```bash
94123
go install github.com/stripe/pg-schema-diff/cmd/pg-schema-diff@latest
95124
```
96-
97125
## Library
98126
```bash
99127
go get -u github.com/stripe/pg-schema-diff@latest

0 commit comments

Comments
 (0)