summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2021-09-01 10:57:00 -0400
committerMike Bayer <mike_mp@zzzcomputing.com>2021-09-01 10:57:51 -0400
commit6f0e6474d8d76cb86ce1b5f5bb3d775862df129a (patch)
tree559282ac1ebb568a651603c2076284bbbe06e4c4
parent578b7d44a7d65aea06e7b077fd35d474ab3c7e3d (diff)
downloadalembic-6f0e6474d8d76cb86ce1b5f5bb3d775862df129a.tar.gz
clarify that only named check constraints are regenerated
Change-Id: Ie0489137122d6ccedfa7c1af44dc8420a0842ee8 References: #400
-rw-r--r--docs/build/batch.rst23
1 files changed, 16 insertions, 7 deletions
diff --git a/docs/build/batch.rst b/docs/build/batch.rst
index 00ccc0f..7b14a64 100644
--- a/docs/build/batch.rst
+++ b/docs/build/batch.rst
@@ -243,11 +243,14 @@ the check constraint also::
recreate operation.
For **unnamed** CHECK constraints, these are still not automatically included
-as part of the batch process as they are often present due to the use of the
+as part of the batch process. Note that this limitation **includes** the CHECK
+constraints generated by the
:class:`~sqlalchemy.types.Boolean` or :class:`~sqlalchemy.types.Enum`
datatypes, which up through SQLAlchemy 1.3 would generate CHECK constraints
-automatically and cannot be tracked to the reflected table. Therefore unnamed
-constraints can be stated explicitly if they are to be included in the
+automatically and cannot be tracked to the reflected table, assuming they are
+generated in an unnamed way.
+
+Unnamed constraints can be stated explicitly if they are to be included in the
recreated table::
with op.batch_alter_table("some_table", table_args=[
@@ -256,10 +259,16 @@ recreated table::
batch_op.add_column(Column('foo', Integer))
batch_op.drop_column('bar')
-Note this only includes CHECK constraints that are explicitly stated
-as part of the table definition, not the CHECK constraints that are generated
-by datatypes such as :class:`~sqlalchemy.types.Boolean` or
-:class:`~sqlalchemy.types.Enum`.
+The above step needs only be taken for CHECK constraints that are explicitly stated
+as part of the table definition.
+
+For CHECK constraints that are generated by datatypes such as
+:class:`~sqlalchemy.types.Boolean` or :class:`~sqlalchemy.types.Enum`, the type
+objects themselves **must be named** in order for their CHECK constraints to be
+included in the batch process. Boolean and Enum datatypes that do not
+have the ``.name`` attribute set will **not** have CHECK constraints
+regenerated. This name can be set by specifying the ``.name`` parameter
+or by using a named Python ``Enum`` object as the source of enumeration.
Dealing with Referencing Foreign Keys
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^