Fix serializing JSONField for migration files.

Review Request #7686 — Created Oct. 9, 2015 and submitted

Information

Djblets
release-0.9.x

Reviewers

JSONField wasn't migration-friendly, as a default value of anything but
a string would attempt to get fed into the database backend, breaking it
when applying migrations. Fixing that manually would then result in
Django thinking the value has changed again, prompting new migrations.

We now have a custom deconstruct() method, which serializes the field
for migrations. We simply encode the default value to a string, much
like how it'd be stored in the database, so that the migration files
will have safe and comparable values.

Successfully generated migration files that had serialized values. I also
attempted to generate new ones after using the hand-fixed migration files,
and saw that Django no longer thought it needed to generate new migration
files.

reviewbot
  1. Tool: Pyflakes
    Processed Files:
        djblets/db/fields.py
    
    
    
    Tool: PEP8 Style Checker
    Processed Files:
        djblets/db/fields.py
    
    
  2. 
      
david
  1. Ship It!
  2. 
      
chipx86
Review request changed

Status: Closed (submitted)

Change Summary:

Pushed to release-0.9.x (b2731cf)
Loading...