Files
zeekay fef1fe39bd a state-only move has to build the table on a database that never had it
Thirty-two migrations move models from the `insights` app into a product app with
SeparateDatabaseAndState and no database operations, most carrying a comment along the
lines of "No database operations - table already exists". That is true of production,
where the table came from `insights` history since squashed away, and false of an empty
database, where nothing creates it at all. A fresh `migrate` died at

    relation "insights_notebook" does not exist

one migration after the move that was supposed to have adopted it, which is why the test
database could not be built and no backend test in this tree could run.

`CreateTableIfNotExists` is right in both directions where `--fake` and a plain
`CreateModel` are each wrong in one: it builds the table from the model as migration
state describes it and skips a database that already has it. Of the 102 moved models, 43
already get their table from `insights.0001_initial` and the operation is a no-op; 52 had
no creator anywhere in the tree and this is what builds them.

It goes in a second SeparateDatabaseAndState rather than beside the state operations,
because Django hands each database operation the state from *before* the state operations
ran -- so a model adopted in the same operation is not yet there to read.

Left out: proxy models, which have no table of their own, and the five migrations whose
own RunSQL already creates the table.
2026-08-09 07:41:34 -07:00
..
…