mirror of
https://github.com/djrobstep/migra.git
synced 2024-08-16 09:10:46 +03:00
better deferrable handling
This commit is contained in:
parent
a0b580eb14
commit
c08064b302
@ -14,7 +14,7 @@ python = "*"
|
||||
sqlbag = "*"
|
||||
six = "*"
|
||||
# schemainspect = {path="../schemainspect"}
|
||||
schemainspect = ">=0.1.1603009162"
|
||||
schemainspect = ">=0.1.1610498640"
|
||||
psycopg2-binary = { version="*", optional = true }
|
||||
|
||||
[tool.poetry.dev-dependencies]
|
||||
|
9
tests/FIXTURES/constraints/a.sql
Normal file
9
tests/FIXTURES/constraints/a.sql
Normal file
@ -0,0 +1,9 @@
|
||||
create table t1(a int);
|
||||
|
||||
create table b(bb int primary key);
|
||||
|
||||
create table t2(a int primary key, bb int references b(bb), price numeric, constraint x check (price > 0));
|
||||
|
||||
create table c(cc int unique);
|
||||
|
||||
create unique index on t1(a);
|
0
tests/FIXTURES/constraints/additions.sql
Normal file
0
tests/FIXTURES/constraints/additions.sql
Normal file
13
tests/FIXTURES/constraints/b.sql
Normal file
13
tests/FIXTURES/constraints/b.sql
Normal file
@ -0,0 +1,13 @@
|
||||
create table b(bb int primary key);
|
||||
|
||||
create table t2(a int, bb int references b(bb) DEFERRABLE INITIALLY deferred);
|
||||
|
||||
create table t1(a int primary key, price numeric, constraint x check (price > 0));
|
||||
|
||||
create table c(cc int unique);
|
||||
|
||||
CREATE UNIQUE INDEX c_pkey ON public.c USING btree (cc);
|
||||
|
||||
alter table "public"."c" add constraint "c_pkey" PRIMARY KEY using index "c_pkey" deferrable INITIALLY deferred;
|
||||
|
||||
create unique index on t2(a);
|
33
tests/FIXTURES/constraints/expected.sql
Normal file
33
tests/FIXTURES/constraints/expected.sql
Normal file
@ -0,0 +1,33 @@
|
||||
alter table "public"."t2" drop constraint "x";
|
||||
|
||||
alter table "public"."t2" drop constraint "t2_bb_fkey";
|
||||
|
||||
alter table "public"."t2" drop constraint "t2_pkey";
|
||||
|
||||
drop index if exists "public"."t1_a_idx";
|
||||
|
||||
drop index if exists "public"."t2_pkey";
|
||||
|
||||
alter table "public"."c" alter column "cc" set not null;
|
||||
|
||||
alter table "public"."t1" add column "price" numeric;
|
||||
|
||||
alter table "public"."t1" alter column "a" set not null;
|
||||
|
||||
alter table "public"."t2" drop column "price";
|
||||
|
||||
alter table "public"."t2" alter column "a" drop not null;
|
||||
|
||||
CREATE UNIQUE INDEX c_pkey ON public.c USING btree (cc);
|
||||
|
||||
CREATE UNIQUE INDEX t1_pkey ON public.t1 USING btree (a);
|
||||
|
||||
CREATE UNIQUE INDEX t2_a_idx ON public.t2 USING btree (a);
|
||||
|
||||
alter table "public"."c" add constraint "c_pkey" PRIMARY KEY using index "c_pkey" DEFERRABLE INITIALLY DEFERRED;
|
||||
|
||||
alter table "public"."t1" add constraint "t1_pkey" PRIMARY KEY using index "t1_pkey";
|
||||
|
||||
alter table "public"."t1" add constraint "x" CHECK ((price > (0)::numeric));
|
||||
|
||||
alter table "public"."t2" add constraint "t2_bb_fkey" FOREIGN KEY (bb) REFERENCES b(bb) DEFERRABLE INITIALLY DEFERRED;
|
0
tests/FIXTURES/constraints/expected2.sql
Normal file
0
tests/FIXTURES/constraints/expected2.sql
Normal file
@ -78,6 +78,7 @@ dependencies
|
||||
dependencies2
|
||||
dependencies3
|
||||
dependencies4
|
||||
constraints
|
||||
""".split()
|
||||
|
||||
# fixtures = [(_, ) for _ in fixtures]
|
||||
|
Loading…
Reference in New Issue
Block a user