mirror of
https://github.com/simonw/sqlite-utils.git
synced 2026-09-07 17:14:09 +02:00
The line under "Custom transformations with .transform_sql()" said
`.transform()` "does not automatically upgrade indexes, views or triggers".
All three parts are wrong, and the trigger one is wrong in the dangerous
direction. Measured on current main:
rename a column triggers ['trg'] -> [] views kept indexes kept
change a type triggers ['trg'] -> [] views kept indexes kept
drop a column triggers ['trg'] -> [] views kept indexes kept
* Indexes *are* handled. `transform_sql()` captures each one before the old
table is dropped and reissues its CREATE INDEX, rewriting a renamed
column: `CREATE INDEX "idx" ON "t" ("new_name")`.
* Views are kept, and were already documented accurately under "Tables
referenced by views" -- so the old sentence also contradicted a section
four paragraphs above it.
* Triggers are not merely "not upgraded". They are **dropped**. SQLite
deletes a table's triggers with the table, and `transform_sql()` never
captures them. A reader told the trigger was not *upgraded* would expect
it to still exist, possibly stale. It is gone.
Replaces the sentence with an "Indexes and triggers" section covering what
actually happens, including the `UNIQUE`-constraint index case (not
reissued, because the constraint is reproduced in the new CREATE TABLE) and
the TransformError raised for any other index without stored SQL.
The trigger part carries a recipe using `table.triggers_dict`, with the
caveat that a captured trigger body still names the old columns. Both the
recipe and every claim above were run against main before being written.
Docs build clean under `sphinx-build -W`.
Closes #849
|
||
|---|---|---|
| .. | ||
| _static/js | ||
| _templates | ||
| .gitignore | ||
| changelog.rst | ||
| cli-reference.rst | ||
| cli.rst | ||
| codespell-ignore-words.txt | ||
| conf.py | ||
| contributing.rst | ||
| index.rst | ||
| installation.rst | ||
| Makefile | ||
| migrations.rst | ||
| plugins.rst | ||
| python-api.rst | ||
| reference.rst | ||
| tutorial.ipynb | ||
| upgrading.rst | ||