Postgresql needs typecasting for turning char fields into native UUID fields.
Conditionally run the necesary SQL for this to happen. GitLab issue #266 Thanks to Baptiste GAULLET @bat79a for finding the solution.
This commit is contained in:
@@ -1,12 +1,12 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
import uuid
|
||||
|
||||
from django.db import connection, migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('documents', '0031_convert_uuid'),
|
||||
]
|
||||
@@ -18,3 +18,13 @@ class Migration(migrations.Migration):
|
||||
field=models.UUIDField(default=uuid.uuid4, editable=False),
|
||||
),
|
||||
]
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(Migration, self).__init__(*args, **kwargs)
|
||||
|
||||
if connection.vendor == 'postgresql':
|
||||
self.operations.insert(
|
||||
0, migrations.RunSQL(
|
||||
'ALTER TABLE documents_document ALTER COLUMN uuid SET DATA TYPE UUID USING uuid::uuid;'
|
||||
)
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user