mirror of
https://github.com/simonw/sqlite-utils.git
synced 2026-09-21 07:54:24 +02:00
Preserve CHECK constraints when transforming a table
.transform() rebuilds from PRAGMA metadata, which doesn't expose CHECK constraints, so they were silently dropped. Pull them from the schema and re-add them to the rebuilt table.
This commit is contained in:
parent
79117b9d11
commit
265f85052b
3 changed files with 304 additions and 2 deletions
|
|
@ -1505,6 +1505,8 @@ To keep the original table around instead of dropping it, pass the ``keep_table=
|
|||
|
||||
table.transform(types={"age": int}, keep_table="original_table")
|
||||
|
||||
``CHECK`` constraints are preserved across a transform. If a column referenced by a constraint is renamed the constraint is updated to match, and if such a column is dropped the constraint is dropped along with it.
|
||||
|
||||
This method raises a ``sqlite_utils.db.TransformError`` exception if the table cannot be transformed, usually because there are existing constraints or indexes that are incompatible with modifications to the columns.
|
||||
|
||||
.. _python_api_transform_alter_column_types:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue