primary keys from character strings to integers, and makes corresponding code changes. This was prompted by database limitations discovered when trying to make DocAlias use a m2m document field; with 255 long strings as primary keys for Document and DocAlias this violated the MySQL database limitations. Changing the primary keys to integers should also improve efficiency. Due to the data migrations which create the new integer primary keys and adds corresponding integer foreign keys matching the previous string foreign keys in all tables having foreign keys to Document and DocAlias, some of these migrations take a long time. The total set of migrations are expected to have a runtime on the order of 2 hours. - Legacy-Id: 16237
34 lines
1.1 KiB
Python
34 lines
1.1 KiB
Python
# -*- coding: utf-8 -*-
|
|
# Generated by Django 1.11.20 on 2019-05-21 05:31
|
|
from __future__ import unicode_literals
|
|
|
|
import sys, time
|
|
|
|
from django.db import migrations
|
|
|
|
def timestamp(apps, schema_editor):
|
|
sys.stderr.write('\n %s' % time.strftime('%Y-%m-%d %H:%M:%S'))
|
|
|
|
class Migration(migrations.Migration):
|
|
|
|
dependencies = [
|
|
('doc', '0019_rename_field_document2'),
|
|
]
|
|
|
|
operations = [
|
|
# Copy the doc IDs from the explicit m2m table to the implicit table
|
|
migrations.RunPython(timestamp, timestamp),
|
|
migrations.RunSQL(
|
|
"INSERT INTO doc_document_formal_languages SELECT id,document_id,formallanguagename_id FROM doc_documentlanguages;",
|
|
""),
|
|
migrations.RunPython(timestamp, timestamp),
|
|
migrations.RunSQL(
|
|
"INSERT INTO doc_document_states SELECT id,document_id,state_id FROM doc_documentstates;",
|
|
""),
|
|
migrations.RunPython(timestamp, timestamp),
|
|
migrations.RunSQL(
|
|
"INSERT INTO doc_document_tags SELECT id,document_id,doctagname_id FROM doc_documenttags;",
|
|
""),
|
|
migrations.RunPython(timestamp, timestamp),
|
|
]
|