Skip to content
This repository has been archived by the owner on Jan 9, 2019. It is now read-only.

Migrations: update id{tool,command}s #65

Merged
merged 3 commits into from
Nov 3, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion fpr/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@
.. moduleauthor:: Justin Simpson <jsimpson@artefactual.com>
"""

__version__ = '1.7.1'
__version__ = '1.7.2'
32 changes: 31 additions & 1 deletion fpr/migrations/0015_pronom_92.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,43 @@
import os

from django.core.management import call_command
from django.db import migrations, models
from django.db import migrations


def data_migration(apps, schema_editor):
fixture_file = os.path.join(os.path.dirname(__file__), 'pronom_92.json')
call_command('loaddata', fixture_file, app_label='fpr')

Format = apps.get_model('fpr', 'Format')
FormatVersion = apps.get_model('fpr', 'FormatVersion')

Format.objects.filter(uuid="9b3f9406-a375-4b66-9081-61a317e68cbf") \
.update(group_id="fdf9e267-a18c-46a4-a162-b81bcba6322f")

Format.objects.filter(uuid="d4bfbd9b-15fc-4992-98cb-7cea13879307") \
.update(group_id="57361413-1c3b-405d-a9c0-7d3ea381090e")

Format.objects.filter(uuid="204309aa-fd1a-47a3-9759-cc5dd5e5a5cc") \
.update(group_id="57361413-1c3b-405d-a9c0-7d3ea381090e")

Format.objects.filter(uuid="51cc4e02-c7ef-404e-b8e7-025f60f3efea") \
.update(group_id="57361413-1c3b-405d-a9c0-7d3ea381090e")

Format.objects.filter(uuid="082c3b92-4940-4b77-8df2-d04be20f3a9b") \
.update(group_id="57361413-1c3b-405d-a9c0-7d3ea381090e")

Format.objects.filter(uuid="996b0720-d6a5-47b5-acaa-3acab09e0a5c") \
.update(group_id="57361413-1c3b-405d-a9c0-7d3ea381090e")

Format.objects.filter(uuid="651911e6-0ff3-40a4-ad37-ec5149367c6e") \
.update(group_id="57361413-1c3b-405d-a9c0-7d3ea381090e")

Format.objects.filter(uuid="20e28493-e0d2-4413-b431-6626f14c3763") \
.update(group_id="57361413-1c3b-405d-a9c0-7d3ea381090e")

FormatVersion.objects.filter(uuid="e2534186-ed8d-4da1-9639-2a80028a2469") \
.update(enabled=False)


class Migration(migrations.Migration):

Expand Down
61 changes: 61 additions & 0 deletions fpr/migrations/0016_update_idtools.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# -*- coding: utf-8 -*-

from __future__ import unicode_literals

from django.db import migrations


def data_migration(apps, schema_editor):
IDTool = apps.get_model('fpr', 'IDTool')
IDCommand = apps.get_model('fpr', 'IDCommand')

# Update Fido tool
tool = IDTool.objects.get(uuid='c33c9d4d-121f-4db1-aa31-3d248c705e44')
tool.version = '1.3.7'
tool._slug = 'fido-137'
tool.save()

# Create new command using the new version of Fido
old_command = IDCommand.objects.get(uuid='a8e45bc1-eb35-4545-885c-dd552f1fde9a', enabled=True)
IDCommand.objects.create(
uuid='76006ad7-a401-48f6-98f6-2efc01003276',
description=u'Identify using Fido',
config=old_command.config,
script=old_command.script,
script_type=old_command.script_type,
tool=tool,
enabled=True
)
old_command.enabled = False
old_command.save()

# Update Siegfried tool
tool = IDTool.objects.get(uuid='454df69d-5cc0-49fc-93e4-6fbb6ac659e7')
tool.version = '1.7.6'
tool._slug = 'siegfried-176'
tool.save()

# Create new command using the new version of Siegfried
old_command = IDCommand.objects.get(uuid='9d2cefc1-2bd2-44e4-8d55-6cf8151eecff', enabled=True)
IDCommand.objects.create(
uuid='df074736-e2f7-4102-b25d-569c099d410c',
description=old_command.description,
config=old_command.config,
script=old_command.script,
script_type=old_command.script_type,
tool=tool,
enabled=True
)
old_command.enabled = False
old_command.save()


class Migration(migrations.Migration):

dependencies = [
('fpr', '0015_pronom_92'),
]

operations = [
migrations.RunPython(data_migration),
]
Loading