Add BigAutoField for BlockCompletion primary key.
This commit is contained in:
@@ -5,7 +5,9 @@ from django.db import models
|
||||
|
||||
|
||||
class CharNullField(models.CharField):
|
||||
"""CharField that stores NULL but returns ''"""
|
||||
"""
|
||||
CharField that stores NULL but returns ''
|
||||
"""
|
||||
|
||||
description = "CharField that stores NULL but returns ''"
|
||||
|
||||
@@ -26,3 +28,31 @@ class CharNullField(models.CharField):
|
||||
return None
|
||||
else:
|
||||
return value
|
||||
|
||||
|
||||
class BigAutoField(models.AutoField):
|
||||
"""
|
||||
AutoField that uses BigIntegers.
|
||||
|
||||
This exists in Django as of version 1.10.
|
||||
"""
|
||||
|
||||
def db_type(self, connection):
|
||||
"""
|
||||
The type of the field to insert into the database.
|
||||
"""
|
||||
conn_module = type(connection).__module__
|
||||
if "mysql" in conn_module:
|
||||
return "bigint AUTO_INCREMENT"
|
||||
elif "postgres" in conn_module:
|
||||
return "bigserial"
|
||||
else:
|
||||
return super(BigAutoField, self).db_type(connection)
|
||||
|
||||
def rel_db_type(self, connection):
|
||||
"""
|
||||
The type to be used by relations pointing to this field.
|
||||
|
||||
Not used until Django 1.10.
|
||||
"""
|
||||
return "bigint"
|
||||
|
||||
Reference in New Issue
Block a user