diff options
-rw-r--r-- | docs/build/batch.rst | 23 |
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 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |