Rework how local database state is tracked.

Review Request #9598 — Created Feb. 7, 2018 and submitted

Information

Django Evolution
master
224e17a...

Reviewers

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 to database_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.

Description From Last Updated

F401 'django.utils.six' imported but unused

reviewbotreviewbot

E501 line too long (80 > 79 characters)

reviewbotreviewbot

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

reviewbotreviewbot

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

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

flake8

chipx86
chipx86
Review request changed
Change Summary:
  • Added exceptions for index operations.
  • Added unit tests.
Commit:
18f6c37c878a77c2fe982acd87a7824a1bbb0a36
e417bbb7304c5c0d6e0dd7eed7a37a5dd00200dd

Checks run (1 failed, 1 succeeded)

flake8 failed.
JSHint passed.

flake8

chipx86
david
  1. Ship It!

  2. 
      
chipx86
david
  1. Ship It!
  2. 
      
chipx86
Review request changed
Status:
Completed
Change Summary:
Pushed to master (6c734d6)