summaryrefslogtreecommitdiff
path: root/archaeological_finds/migrations/0130_data_discovery_method.py
blob: 56a1efb1fefee77bbda6a0f3c67abd236ce62d68 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import os

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


def load_data(apps, __):
    DiscoveryMethod = apps.get_model("archaeological_finds", "discoverymethod")
    if not DiscoveryMethod.objects.count():
        migration = "0130_data_discovery_method.json"
        json_path = os.sep.join(os.path.abspath(__file__).split(os.sep)[:-1] + [migration])
        call_command("loaddata", json_path)


class Migration(migrations.Migration):

    dependencies = [
        ('archaeological_finds', '0129_discovery_method'),
    ]

    operations = [
        migrations.RunPython(load_data)
    ]