fix user length
This commit is contained in:
parent
2c41b17bc4
commit
65891f5455
2 changed files with 17 additions and 0 deletions
|
@ -32,4 +32,19 @@ def monkey_patch_username():
|
||||||
if isinstance(v, MaxLengthValidator):
|
if isinstance(v, MaxLengthValidator):
|
||||||
v.limit_value = 255
|
v.limit_value = 255
|
||||||
|
|
||||||
|
def apply_patch():
|
||||||
|
from django.db import connection, transaction
|
||||||
|
cursor = connection.cursor()
|
||||||
|
table = connection.introspection.get_table_description(cursor, User._meta.db_table)
|
||||||
|
sql = []
|
||||||
|
for row in table:
|
||||||
|
if row.name in NEW_LENGTH and row.internal_size != NEW_LENGTH[row.name]:
|
||||||
|
sql.append('ALTER TABLE "%s" ALTER "%s" TYPE varchar(%d)' % (User._meta.db_table, row.name, NEW_LENGTH[row.name]))
|
||||||
|
|
||||||
|
for q in sql:
|
||||||
|
cursor.execute(q)
|
||||||
|
if sql:
|
||||||
|
transaction.commit()
|
||||||
|
|
||||||
|
|
||||||
monkey_patch_username()
|
monkey_patch_username()
|
||||||
|
|
|
@ -31,6 +31,8 @@ class Command(BaseCommand):
|
||||||
print(sql)
|
print(sql)
|
||||||
cursor.execute(sql)
|
cursor.execute(sql)
|
||||||
|
|
||||||
|
app.monkey_patch.apply_patch()
|
||||||
|
|
||||||
if settings.DB_GIN_TRGM:
|
if settings.DB_GIN_TRGM:
|
||||||
import entity.models
|
import entity.models
|
||||||
import document.models
|
import document.models
|
||||||
|
|
Loading…
Reference in a new issue