# Generated by Django 2.2.18 on 2021-03-25 11:57

from django.db import migrations, models
import django.db.models.deletion
import django.contrib.postgres.fields.jsonb
import core.models.harvest


class Migration(migrations.Migration):

    dependencies = [
        ('core', '0005_sharekit_repository'),
    ]

    operations = [
        migrations.RenameModel(
            old_name='OAIPMHSet',
            new_name='HarvestSource',
        ),
        migrations.RenameModel(
            old_name='OAIPMHHarvest',
            new_name='Harvest',
        ),
        migrations.AlterModelOptions(
            name='harvest',
            options={},
        ),
        migrations.AlterField(
            model_name='harvest',
            name='source',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='core.HarvestSource'),
        ),
        migrations.AlterModelOptions(
            name='harvestsource',
            options={},
        ),
        migrations.RemoveField(
            model_name='arrangement',
            name='collection',
        ),
        migrations.RemoveField(
            model_name='arrangement',
            name='dataset',
        ),
        migrations.RemoveField(
            model_name='document',
            name='arrangement',
        ),
        migrations.AlterField(
            model_name='harvestsource',
            name='spec',
            field=models.CharField(help_text="The code for the 'set' you want to harvest", max_length=255),
        ),
        migrations.AddField(
            model_name='harvest',
            name='purge_after',
            field=models.DateTimeField(blank=True, null=True),
        ),
        migrations.AddField(
            model_name='harvestsource',
            name='delete_policy',
            field=models.CharField(choices=[('no', 'No'), ('persistent', 'Persistent'), ('transient', 'Transient')], default='transient', max_length=50),
        ),
        migrations.AddField(
            model_name='harvestsource',
            name='purge_interval',
            field=django.contrib.postgres.fields.jsonb.JSONField(default=core.models.harvest.thirty_days_default),
        ),
        migrations.CreateModel(
            name='DatasetVersion',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('is_current', models.BooleanField(default=False)),
                ('created_at', models.DateTimeField(auto_now_add=True)),
                ('version', models.CharField(blank=True, max_length=50)),
                ('dataset', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='versions',
                                              to='core.Dataset'),),
            ],
        ),
        migrations.AddField(
            model_name='collection',
            name='dataset_version',
            field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='core.DatasetVersion'),
        ),
        migrations.AddField(
            model_name='document',
            name='dataset_version',
            field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='core.DatasetVersion'),
        ),
        migrations.AddField(
            model_name='elasticindex',
            name='dataset_version',
            field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, related_name='indices', to='core.DatasetVersion'),
        ),
        migrations.AlterField(
            model_name='elasticindex',
            name='dataset',
            field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, related_name='indices', to='core.Dataset'),
        ),
    ]
