Skip to content
Snippets Groups Projects
Commit 4eb1ed4f authored by Erwan Rouchet's avatar Erwan Rouchet Committed by Bastien Abadie
Browse files

Randomize revisions

parent e060cc5c
No related branches found
No related tags found
No related merge requests found
# Generated by Django 3.1.3 on 2020-11-30 10:40
import os
import uuid
from django.db import migrations, models
......@@ -53,19 +54,22 @@ def migrate_data_sources(apps, schema_editor):
'type': str(source.type),
}
)
revision, _ = repo.revisions.get_or_create(
hash='0' * 32,
message='Migrated DataSource',
author='Arkindex',
)
# There can be multiple DataSources with the same slug and revision,
# but with a different type, so we have to use get_or_create.
version, _ = worker.workerversion_set.get_or_create(
# To ensure we cannot get duplicate worker version IDs when re-applying
# unique constraints later, we just keep on trying to get a new revision.
created = False
while not created:
revision, created = repo.revisions.get_or_create(
hash=uuid.uuid4().hex,
message='Migrated DataSource',
author='Arkindex',
)
version = worker.workerversion_set.create(
revision=revision,
defaults={
'configuration': {}
},
configuration={},
)
source.elements.update(source=None, worker_version=version)
source.classifications.update(source=None, worker_version=version)
source.transcriptions.update(source=None, worker_version=version)
......
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