Batch together operations for a SQLite table rebuild.

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

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).

Summary ID
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.
06d4f831015a3e766080d0c641bb1f372fd464fa
Description From Last Updated

F401 'django_evolution.db.common.SQLResult' imported but unused

reviewbotreviewbot

F841 local variable 'database_state' is assigned to but never used

reviewbotreviewbot

F812 list comprehension redefines 'field' from line 87

reviewbotreviewbot

F841 local variable 'create_indexes' is assigned to but never used

reviewbotreviewbot
Checks run (1 failed, 1 succeeded)
flake8 failed.
JSHint passed.

flake8

chipx86
david
  1. Ship It!
  2. 
      
chipx86
Review request changed

Status: Closed (submitted)

Change Summary:

Pushed to master (5288425)
Loading...