Used a database feature to prevent the jsonb test model from being migrated.

Thanks Tim for the review.
This commit is contained in:
Simon Charette 2016-09-10 19:20:16 -04:00
parent e07b18252b
commit 32c0d823e5
4 changed files with 19 additions and 42 deletions

View file

@ -216,9 +216,6 @@ class Migration(migrations.Migration):
},
bases=(models.Model,),
),
]
pg_94_operations = [
migrations.CreateModel(
name='JSONModel',
fields=[
@ -227,17 +224,8 @@ class Migration(migrations.Migration):
('field_custom', JSONField(null=True, blank=True, encoder=DjangoJSONEncoder)),
],
options={
'required_db_features': {'has_jsonb_datatype'},
},
bases=(models.Model,),
),
]
def apply(self, project_state, schema_editor, collect_sql=False):
try:
PG_VERSION = schema_editor.connection.pg_version
except AttributeError:
pass # We are probably not on PostgreSQL
else:
if PG_VERSION >= 90400:
self.operations = self.operations + self.pg_94_operations
return super(Migration, self).apply(project_state, schema_editor, collect_sql)