mirror of
https://github.com/djrobstep/migra.git
synced 2024-09-11 05:45:51 +03:00
Support non-valid->validate constraint creation
This commit is contained in:
parent
f95f98a905
commit
2e6ed06b2d
@ -122,7 +122,10 @@ def statements_from_differences(
|
||||
for k, v in added.items():
|
||||
if not has_uncreated_dependencies(v, pending_creations):
|
||||
if k in pending_creations:
|
||||
statements.append(v.create_statement)
|
||||
if hasattr(v, 'safer_create_statements'):
|
||||
statements += v.safer_create_statements
|
||||
else:
|
||||
statements.append(v.create_statement)
|
||||
pending_creations.remove(k)
|
||||
if modifications:
|
||||
for k, v in modified.items():
|
||||
@ -134,7 +137,10 @@ def statements_from_differences(
|
||||
if creations:
|
||||
if not has_uncreated_dependencies(v, pending_creations):
|
||||
if k in pending_creations:
|
||||
statements.append(v.create_statement)
|
||||
if hasattr(v, 'safer_create_statements'):
|
||||
statements += v.safer_create_statements
|
||||
else:
|
||||
statements.append(v.create_statement)
|
||||
pending_creations.remove(k)
|
||||
after = pending_drops | pending_creations
|
||||
if not after:
|
||||
|
18
poetry.lock
generated
18
poetry.lock
generated
@ -15,9 +15,9 @@ optional = false
|
||||
python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*"
|
||||
|
||||
[package.extras]
|
||||
dev = ["coverage[toml] (>=5.0.2)", "hypothesis", "pympler", "pytest (>=4.3.0)", "six", "mypy", "pytest-mypy-plugins", "zope.interface", "furo", "sphinx", "sphinx-notfound-page", "pre-commit", "cloudpickle"]
|
||||
docs = ["furo", "sphinx", "zope.interface", "sphinx-notfound-page"]
|
||||
tests = ["coverage[toml] (>=5.0.2)", "hypothesis", "pympler", "pytest (>=4.3.0)", "six", "mypy", "pytest-mypy-plugins", "zope.interface", "cloudpickle"]
|
||||
dev = ["coverage[toml] (>=5.0.2)", "hypothesis", "pympler", "pytest (>=4.3.0)", "six", "mypy", "pytest-mypy-plugins", "zope-interface", "furo", "sphinx", "sphinx-notfound-page", "pre-commit", "cloudpickle"]
|
||||
docs = ["furo", "sphinx", "zope-interface", "sphinx-notfound-page"]
|
||||
tests = ["coverage[toml] (>=5.0.2)", "hypothesis", "pympler", "pytest (>=4.3.0)", "six", "mypy", "pytest-mypy-plugins", "zope-interface", "cloudpickle"]
|
||||
tests_no_zope = ["coverage[toml] (>=5.0.2)", "hypothesis", "pympler", "pytest (>=4.3.0)", "six", "mypy", "pytest-mypy-plugins", "cloudpickle"]
|
||||
|
||||
[[package]]
|
||||
@ -127,7 +127,7 @@ zipp = ">=0.5"
|
||||
|
||||
[package.extras]
|
||||
docs = ["sphinx", "jaraco.packaging (>=8.2)", "rst.linker (>=1.9)"]
|
||||
testing = ["pytest (>=4.6)", "pytest-checkdocs (>=2.4)", "pytest-flake8", "pytest-cov", "pytest-enabler (>=1.0.1)", "packaging", "pep517", "pyfakefs", "flufl.flake8", "pytest-black (>=0.3.7)", "pytest-mypy", "importlib-resources (>=1.3)"]
|
||||
testing = ["pytest (>=4.6)", "pytest-checkdocs (>=2.4)", "pytest-flake8", "pytest-cov", "pytest-enabler (>=1.0.1)", "packaging", "pep517", "pyfakefs", "flufl-flake8", "pytest-black (>=0.3.7)", "pytest-mypy", "importlib-resources (>=1.3)"]
|
||||
|
||||
[[package]]
|
||||
name = "iniconfig"
|
||||
@ -340,7 +340,7 @@ jupyter = ["ipywidgets (>=7.5.1,<8.0.0)"]
|
||||
|
||||
[[package]]
|
||||
name = "schemainspect"
|
||||
version = "3.1.1652015119"
|
||||
version = "3.1.1658648837"
|
||||
description = "Schema inspection for PostgreSQL (and possibly others)"
|
||||
category = "main"
|
||||
optional = false
|
||||
@ -450,7 +450,7 @@ python-versions = ">=3.7"
|
||||
|
||||
[package.extras]
|
||||
docs = ["sphinx", "jaraco.packaging (>=9)", "rst.linker (>=1.9)", "jaraco.tidelift (>=1.4)"]
|
||||
testing = ["pytest (>=6)", "pytest-checkdocs (>=2.4)", "pytest-flake8", "pytest-cov", "pytest-enabler (>=1.3)", "jaraco.itertools", "func-timeout", "pytest-black (>=0.3.7)", "pytest-mypy (>=0.9.1)"]
|
||||
testing = ["pytest (>=6)", "pytest-checkdocs (>=2.4)", "pytest-flake8", "pytest-cov", "pytest-enabler (>=1.3)", "jaraco-itertools", "func-timeout", "pytest-black (>=0.3.7)", "pytest-mypy (>=0.9.1)"]
|
||||
|
||||
[extras]
|
||||
pg = ["psycopg2-binary"]
|
||||
@ -458,7 +458,7 @@ pg = ["psycopg2-binary"]
|
||||
[metadata]
|
||||
lock-version = "1.1"
|
||||
python-versions = ">=3.7,<4"
|
||||
content-hash = "34e57ac69769d227248e4f881d1842dc9e78e41ca22af0574ce062ed8f8f2f86"
|
||||
content-hash = "21ffd0af5c9902c2d943b8bf9414108c42f6a45a807f8130a4105fa341d86a85"
|
||||
|
||||
[metadata.files]
|
||||
atomicwrites = [
|
||||
@ -648,8 +648,8 @@ rich = [
|
||||
{file = "rich-12.5.1.tar.gz", hash = "sha256:63a5c5ce3673d3d5fbbf23cd87e11ab84b6b451436f1b7f19ec54b6bc36ed7ca"},
|
||||
]
|
||||
schemainspect = [
|
||||
{file = "schemainspect-3.1.1652015119-py3-none-any.whl", hash = "sha256:b98cf19f76a8e5110c2a81f74bf72e7ae52697895f5910f40c0cd1d64cb7c445"},
|
||||
{file = "schemainspect-3.1.1652015119.tar.gz", hash = "sha256:7eb05190b52e1520c1ea573abc39eac47752b647708b6d7dfc350345737e44a1"},
|
||||
{file = "schemainspect-3.1.1658648837-py3-none-any.whl", hash = "sha256:db34c334a4af0fa4710d3e1cd075efb17f3b4760ff0e9bb779bbb4a78ad13f81"},
|
||||
{file = "schemainspect-3.1.1658648837.tar.gz", hash = "sha256:601e9fa5fc243cb645201ea0064d2f2993023ee7c97fa08d9d2fd36dc806ddfc"},
|
||||
]
|
||||
six = [
|
||||
{file = "six-1.16.0-py2.py3-none-any.whl", hash = "sha256:8abb2f1d86890a2dfb989f9a77cfcfd3e47c2a354b01111771326f8aa26e0254"},
|
||||
|
@ -41,6 +41,10 @@ alter table "public"."t1" add constraint "t1_pkey" PRIMARY KEY using index "t1_p
|
||||
|
||||
alter table "public"."circles" add constraint "circles_c_excl" EXCLUDE USING gist (c WITH &&);
|
||||
|
||||
alter table "public"."t1" add constraint "x" CHECK ((price > (0)::numeric));
|
||||
alter table "public"."t1" add constraint "x" CHECK ((price > (0)::numeric)) not valid;
|
||||
|
||||
alter table "public"."t2" add constraint "t2_bb_fkey" FOREIGN KEY (bb) REFERENCES b(bb) DEFERRABLE INITIALLY DEFERRED;
|
||||
alter table "public"."t1" validate constraint "x";
|
||||
|
||||
alter table "public"."t2" add constraint "t2_bb_fkey" FOREIGN KEY (bb) REFERENCES b(bb) DEFERRABLE INITIALLY DEFERRED not valid;
|
||||
|
||||
alter table "public"."t2" validate constraint "t2_bb_fkey";
|
@ -134,13 +134,21 @@ alter table "public"."order_items" add constraint "order_items_pkey" PRIMARY KEY
|
||||
|
||||
alter table "public"."products" add constraint "products_pkey" PRIMARY KEY using index "products_pkey";
|
||||
|
||||
alter table "public"."order_items" add constraint "order_items_order_id_fkey" FOREIGN KEY (order_id) REFERENCES orders(order_id) ON DELETE CASCADE;
|
||||
alter table "public"."order_items" add constraint "order_items_order_id_fkey" FOREIGN KEY (order_id) REFERENCES orders(order_id) ON DELETE CASCADE not valid;
|
||||
|
||||
alter table "public"."order_items" add constraint "order_items_product_no_fkey" FOREIGN KEY (product_no) REFERENCES products(product_no) ON DELETE RESTRICT;
|
||||
alter table "public"."order_items" validate constraint "order_items_order_id_fkey";
|
||||
|
||||
alter table "public"."products" add constraint "y" CHECK ((price > (0)::numeric));
|
||||
alter table "public"."order_items" add constraint "order_items_product_no_fkey" FOREIGN KEY (product_no) REFERENCES products(product_no) ON DELETE RESTRICT not valid;
|
||||
|
||||
alter table "public"."products" add constraint "x" CHECK ((price > (10)::numeric));
|
||||
alter table "public"."order_items" validate constraint "order_items_product_no_fkey";
|
||||
|
||||
alter table "public"."products" add constraint "y" CHECK ((price > (0)::numeric)) not valid;
|
||||
|
||||
alter table "public"."products" validate constraint "y";
|
||||
|
||||
alter table "public"."products" add constraint "x" CHECK ((price > (10)::numeric)) not valid;
|
||||
|
||||
alter table "public"."products" validate constraint "x";
|
||||
|
||||
set check_function_bodies = off;
|
||||
|
||||
|
@ -130,13 +130,21 @@ alter table "public"."order_items" add constraint "order_items_pkey" PRIMARY KEY
|
||||
|
||||
alter table "public"."products" add constraint "products_pkey" PRIMARY KEY using index "products_pkey";
|
||||
|
||||
alter table "public"."order_items" add constraint "order_items_order_id_fkey" FOREIGN KEY (order_id) REFERENCES orders(order_id) ON DELETE CASCADE;
|
||||
alter table "public"."order_items" add constraint "order_items_order_id_fkey" FOREIGN KEY (order_id) REFERENCES orders(order_id) ON DELETE CASCADE not valid;
|
||||
|
||||
alter table "public"."order_items" add constraint "order_items_product_no_fkey" FOREIGN KEY (product_no) REFERENCES products(product_no) ON DELETE RESTRICT;
|
||||
alter table "public"."order_items" validate constraint "order_items_order_id_fkey";
|
||||
|
||||
alter table "public"."products" add constraint "y" CHECK ((price > (0)::numeric));
|
||||
alter table "public"."order_items" add constraint "order_items_product_no_fkey" FOREIGN KEY (product_no) REFERENCES products(product_no) ON DELETE RESTRICT not valid;
|
||||
|
||||
alter table "public"."products" add constraint "x" CHECK ((price > (10)::numeric));
|
||||
alter table "public"."order_items" validate constraint "order_items_product_no_fkey";
|
||||
|
||||
alter table "public"."products" add constraint "y" CHECK ((price > (0)::numeric)) not valid;
|
||||
|
||||
alter table "public"."products" validate constraint "y";
|
||||
|
||||
alter table "public"."products" add constraint "x" CHECK ((price > (10)::numeric)) not valid;
|
||||
|
||||
alter table "public"."products" validate constraint "x";
|
||||
|
||||
set check_function_bodies = off;
|
||||
|
||||
|
@ -40,12 +40,18 @@ CREATE UNIQUE INDEX entity_bindings_c_entity_id_entity_type_key ON public.entity
|
||||
|
||||
alter table "public"."entity_bindings_a" add constraint "entity_bindings_a_entity_id_entity_type_key" UNIQUE using index "entity_bindings_a_entity_id_entity_type_key";
|
||||
|
||||
alter table "public"."entity_bindings_a" add constraint "entity_type must be A" CHECK ((entity_type = 'A'::text));
|
||||
alter table "public"."entity_bindings_a" add constraint "entity_type must be A" CHECK ((entity_type = 'A'::text)) not valid;
|
||||
|
||||
alter table "public"."entity_bindings_a" validate constraint "entity_type must be A";
|
||||
|
||||
alter table "public"."entity_bindings_b" add constraint "entity_bindings_b_entity_id_entity_type_key" UNIQUE using index "entity_bindings_b_entity_id_entity_type_key";
|
||||
|
||||
alter table "public"."entity_bindings_b" add constraint "entity_type must be B" CHECK ((entity_type = 'B'::text));
|
||||
alter table "public"."entity_bindings_b" add constraint "entity_type must be B" CHECK ((entity_type = 'B'::text)) not valid;
|
||||
|
||||
alter table "public"."entity_bindings_b" validate constraint "entity_type must be B";
|
||||
|
||||
alter table "public"."entity_bindings_c" add constraint "entity_bindings_c_entity_id_entity_type_key" UNIQUE using index "entity_bindings_c_entity_id_entity_type_key";
|
||||
|
||||
alter table "public"."entity_bindings_c" add constraint "entity_type must be C" CHECK ((entity_type = 'C'::text));
|
||||
alter table "public"."entity_bindings_c" add constraint "entity_type must be C" CHECK ((entity_type = 'C'::text)) not valid;
|
||||
|
||||
alter table "public"."entity_bindings_c" validate constraint "entity_type must be C";
|
Loading…
Reference in New Issue
Block a user