mirror of
https://github.com/django/django.git
synced 2025-07-24 05:36:15 +00:00
Used a database feature to prevent the jsonb test model from being migrated.
Thanks Tim for the review.
This commit is contained in:
parent
e07b18252b
commit
32c0d823e5
4 changed files with 19 additions and 42 deletions
|
@ -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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue