Skip to content
Snippets Groups Projects
Commit b58c3695 authored by Samuel GAIST's avatar Samuel GAIST
Browse files

[databases][migration] Split 0004 migration

This migration fails to apply properly when using PostgreSQL.

Separating the data migration and the last field alteration
fixes it.
parent d46e4c98
No related branches found
No related tags found
1 merge request!2551.4.x
......@@ -4,26 +4,6 @@ from __future__ import unicode_literals
from django.db import migrations, models
from beat.backend.python.hash import hashDataset
def compute_hashes(apps, schema_editor):
'''Refreshes each database so datasets/outputs are recreated'''
DatabaseSet = apps.get_model("databases", "DatabaseSet")
if DatabaseSet.objects.count():
print('')
for db_set in DatabaseSet.objects.order_by('id'):
print("Computing hashes for database set '%s/%d/%s/%s'..." % \
(db_set.protocol.database.name, db_set.protocol.database.version,
db_set.protocol.name, db_set.name))
db_set.hash = hashDataset('%s/%d' % (db_set.protocol.database.name, db_set.protocol.database.version),
db_set.protocol.name, db_set.name)
db_set.save()
class Migration(migrations.Migration):
......@@ -42,11 +22,4 @@ class Migration(migrations.Migration):
field=models.CharField(default='', max_length=64),
preserve_default=False,
),
migrations.RunPython(compute_hashes),
migrations.AlterField(
model_name='databaseset',
name='hash',
field=models.CharField(max_length=64, unique=True),
preserve_default=False,
),
]
# -*- coding: utf-8 -*-
# Generated by Django 1.9.13 on 2018-01-25 09:06
from __future__ import unicode_literals
from django.db import migrations, models
from beat.backend.python.hash import hashDataset
def compute_hashes(apps, schema_editor):
'''Refreshes each database so datasets/outputs are recreated'''
DatabaseSet = apps.get_model("databases", "DatabaseSet")
if DatabaseSet.objects.count():
print('')
for db_set in DatabaseSet.objects.order_by('id'):
print("Computing hashes for database set '%s/%d/%s/%s'..." % \
(db_set.protocol.database.name, db_set.protocol.database.version,
db_set.protocol.name, db_set.name))
db_set.hash = hashDataset('%s/%d' % (db_set.protocol.database.name, db_set.protocol.database.version),
db_set.protocol.name, db_set.name)
db_set.save()
class Migration(migrations.Migration):
dependencies = [
('databases', '0004_beat_backend_python_1_5_x'),
]
operations = [
migrations.RunPython(compute_hashes),
]
# -*- coding: utf-8 -*-
# Generated by Django 1.9.13 on 2018-01-25 09:06
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('databases', '0005_databaseset_data_migration'),
]
operations = [
migrations.AlterField(
model_name='databaseset',
name='hash',
field=models.CharField(max_length=64, unique=True),
preserve_default=False,
),
]
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment