Rework how local database state is tracked.

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

chipx86
Django Evolution
master
3603bb3...
django-evolution

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.

  • 0
  • 0
  • 4
  • 0
  • 4
Description From Last Updated
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

Diff:

Revision 3 (+848 -330)

Show changes

Checks run (1 failed, 1 succeeded)

flake8 failed.
JSHint passed.

flake8

chipx86
Review request changed

Change Summary:

Removed unused variables.

Commit:

-e417bbb7304c5c0d6e0dd7eed7a37a5dd00200dd
+3603bb315d8cef00b2777f01dc56f4eccd718173

Diff:

Revision 4 (+845 -330)

Show changes

Checks run (2 succeeded)

flake8 passed.
JSHint passed.
david
  1. Ship It!
  2. 
      
Loading...