Batch together operations for a SQLite table rebuild.

Review Request #11084 — Created July 16, 2020 and submitted — Latest diff uploaded

Information

Django Evolution
master

Reviewers

A while back, Django Evolution introduced AlterTableSQLResult, which
worked with the mutation optimizer to reduce the number of ALTER TABLE
statements required for traditional databases when applying several
evolutions at once. That didn't work with SQLite, though, since SQLite
required a full table rebuild to make most changes.

This change enables these optimized operations through a new
SQLiteAlterTableSQLResult, which is a specialization of
AlterTableSQLResult that supports its own internal operations for
adding/deleting/renaming/changing columns, setting up state that's used
to construct the destination table when rebuilding.

That reduces the number of table rebuilds significantly, making it less
likely that something can go wrong and speeding up a chain of
evolutions.

Unit tests passed on all supported versions of Django, all databases,
and with SQLite 3.24.0 and 3.28.0 (which both handle table alterations
in subtly different ways).

Diff Revision 1

This is not the most recent revision of the diff. The latest diff is revision 2. See what's changed.

orig
1
2

Commits

First Last Summary ID Author
Batch together operations for a SQLite table rebuild.
A while back, Django Evolution introduced `AlterTableSQLResult`, which worked with the mutation optimizer to reduce the number of `ALTER TABLE` statements required for traditional databases when applying several evolutions at once. That didn't work with SQLite, though, since SQLite required a full table rebuild to make most changes. This change enables these optimized operations through a new `SQLiteAlterTableSQLResult`, which is a specialization of `AlterTableSQLResult` that supports its own internal operations for adding/deleting/renaming/changing columns, setting up state that's used to construct the destination table when rebuilding. That reduces the number of table rebuilds significantly, making it less likely that something can go wrong and speeding up a chain of evolutions.
e91775aa836ef7b321f548656b7870b66bbd167a Christian Hammond
django_evolution/db/common.py
django_evolution/db/sql_result.py
django_evolution/db/sqlite3.py
django_evolution/tests/db/sqlite3.py
Loading...