Rework how local database state is tracked.
Review Request #9598 — Created Feb. 7, 2018 and submitted — Latest diff uploaded
When generating evolutions, mutations and database operations need to
track certain state, specifically indexes on tables. These were done
through a "database signature" object, which was a nested set of
dictionaries lacking any formal API. It had problems, namely that it
didn't prevent things like indexes without a name (which was being
generated in some cases), and was hard to maintain. It also wasn't named
appropriately, since it wasn't actually a signature of the database's
state like the other signatures.This change introduces a new
DatabaseState
class, which is the
replacement for the old database signature dictionaries. This has a
formal, documented API for tracking tables and indexes, and handles
checking that the data going into it from callers is valid. It also
handles some of the types of lookups that we used to need various
utility functions for (some of those still remain as part of this
change, and will be removed in a future one).The
database_sig
references had to change todatabase_state
throughout the codebase, which is a large part of why this change is
spread across so many files.
Unit tests pass for all Python versions on all database types for
all versions of Django.