# Generated by Django 2.2.16 on 2020-10-27 19:15

from django.db import migrations, models
import django.db.models.deletion

DELETE_ORPHAN_GALAXY_COLLECTION_IMPORTS = """
DELETE
FROM galaxy_collectionimport
WHERE task_id in
    (SELECT task_id
     FROM galaxy_collectionimport
     WHERE task_id not in
         (SELECT task_id
          FROM ansible_collectionimport));
"""

class Migration(migrations.Migration):

    dependencies = [
        ('galaxy', '0010_add_staging_rejected_repos'),
    ]

    operations = [
        migrations.RunSQL(sql=DELETE_ORPHAN_GALAXY_COLLECTION_IMPORTS,
                          reverse_sql=migrations.RunSQL.noop),
        migrations.AlterField(
            model_name='collectionimport',
            name='task_id',
            field=models.OneToOneField(db_column='task_id', on_delete=django.db.models.deletion.CASCADE, primary_key=True, related_name='galaxy_import', serialize=False, to='ansible.CollectionImport'),
        ),
    ]
