# Generated by Django 4.2.23 on 2025-08-13 12:47

from django.db import migrations, models
import django.db.models.deletion
import pulp_rpm.app.models.package
import pulpcore.app.models.base
import pulpcore.app.util


class Migration(migrations.Migration):

    replaces = [('rpm', '0001_initial'), ('rpm', '0002_updaterecord_reboot_suggested'), ('rpm', '0003_DATA_incorrect_json'), ('rpm', '0004_add_metadata_signing_service_fk'), ('rpm', '0005_optimize_sync'), ('rpm', '0006_opensuse_support'), ('rpm', '0007_checksum_types'), ('rpm', '0008_advisory_pkg_sumtype_as_int'), ('rpm', '0009_revision_null'), ('rpm', '0010_revision_null_redo'), ('rpm', '0011_rpmremote_sles_auth_token'), ('rpm', '0012_remove_pkg_group_env_cat_related_pkgs'), ('rpm', '0013_RAW_rpm_evr_extension'), ('rpm', '0014_rpmrepository_package_retention_policy'), ('rpm', '0015_repo_metadata'), ('rpm', '0016_dist_tree_nofk'), ('rpm', '0017_merge_advisory_collections'), ('rpm', '0018_updatecollection__update_record'), ('rpm', '0019_migrate_updatecollection_data'), ('rpm', '0020_remove_updatecollection_m2m'), ('rpm', '0021_rename_updatecollection_update_record'), ('rpm', '0022_add_collections_related_name'), ('rpm', '0023_increase_distribution_release_short'), ('rpm', '0024_change_subrepo_relation_properties'), ('rpm', '0025_remove_orphaned_subrepos'), ('rpm', '0026_add_gpgcheck_options'), ('rpm', '0027_checksum_null'), ('rpm', '0028_rpmrepository_last_sync_repomd_cheksum'), ('rpm', '0029_rpmpublication_sqlite_metadata'), ('rpm', '0030_DATA_fix_updaterecord'), ('rpm', '0031_modulemd_static_context'), ('rpm', '0032_ulnremote'), ('rpm', '0033_new_distribution_model'), ('rpm', '0034_auto_publish'), ('rpm', '0035_fix_auto_publish'), ('rpm', '0036_checksum_type'), ('rpm', '0037_DATA_remove_rpmrepository_sub_repo'), ('rpm', '0037_update_json_field'), ('rpm', '0038_fix_sync_optimization'), ('rpm', '0039_disttree_digest'), ('rpm', '0040_rpmalternatecontentsource'), ('rpm', '0041_modulemdobsolete'), ('rpm', '0042_alter_repometadatafile_data_type'), ('rpm', '0043_textfield_conversion'), ('rpm', '0044_noartifact_modules'), ('rpm', '0045_modulemd_fields'), ('rpm', '0046_rbac_perms'), ('rpm', '0047_modulemd_datefield'), ('rpm', '0048_artifacts_dependencies_fix'), ('rpm', '0049_profiles_fix'), ('rpm', '0050_alter_addon_pulp_id_alter_checksum_pulp_id_and_more'), ('rpm', '0051_alter_distributiontree_unique_together_and_more'), ('rpm', '0052_modulemd_digest'), ('rpm', '0053_rpmdistribution_generate_repo_config'), ('rpm', '0054_remove_gpg_fields'), ('rpm', '0055_add_repo_config_field'), ('rpm', '0056_remove_rpmpublication_sqlite_metadata_and_more'), ('rpm', '0057_rpmpublication_checksum_type_and_more'), ('rpm', '0058_alter_addon_repository_alter_variant_repository'), ('rpm', '0059_rpmpublication_compression_type_and_more'), ('rpm', '0060_rpmpublication_compression_type_empty'), ('rpm', '0061_fix_modulemd_defaults_digest'), ('rpm', '0062_rpmpackagesigningservice_and_more')]

    initial = True

    dependencies = [
        ('core', '0091_systemid'),
        ('core', '0106_alter_artifactdistribution_distribution_ptr_and_more'),
        ('core', '0114_remove_task_args_remove_task_kwargs'),
    ]

    operations = [
        migrations.CreateModel(
            name='DistributionTree',
            fields=[
                ('content_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='core.content')),
                ('header_version', models.TextField()),
                ('release_name', models.TextField()),
                ('release_short', models.TextField()),
                ('release_version', models.TextField()),
                ('release_is_layered', models.BooleanField(default=False)),
                ('base_product_name', models.TextField(null=True)),
                ('base_product_short', models.TextField(null=True)),
                ('base_product_version', models.TextField(null=True)),
                ('arch', models.TextField()),
                ('build_timestamp', models.FloatField()),
                ('instimage', models.TextField(null=True)),
                ('mainimage', models.TextField(null=True)),
                ('discnum', models.IntegerField(null=True)),
                ('totaldiscs', models.IntegerField(null=True)),
                ('digest', models.TextField()),
                ('_pulp_domain', models.ForeignKey(default=pulpcore.app.util.get_domain_pk, on_delete=django.db.models.deletion.PROTECT, to='core.domain')),
            ],
            options={
                'default_related_name': '%(app_label)s_%(model_name)s',
                'unique_together': {('_pulp_domain', 'digest')},
            },
            bases=('core.content',),
        ),
        migrations.CreateModel(
            name='Package',
            fields=[
                ('content_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='core.content')),
                ('name', models.CharField(max_length=255)),
                ('epoch', models.CharField(max_length=10)),
                ('version', models.CharField(max_length=255)),
                ('release', models.CharField(max_length=255)),
                ('arch', models.CharField(max_length=20)),
                ('pkgId', models.TextField(db_index=True)),
                ('checksum_type', models.TextField(choices=[('unknown', 'unknown'), ('md5', 'md5'), ('sha1', 'sha1'), ('sha1', 'sha1'), ('sha224', 'sha224'), ('sha256', 'sha256'), ('sha384', 'sha384'), ('sha512', 'sha512')])),
                ('summary', models.TextField()),
                ('description', models.TextField()),
                ('url', models.TextField()),
                ('changelogs', models.JSONField(default=list)),
                ('files', models.JSONField(default=list)),
                ('requires', models.JSONField(default=list)),
                ('provides', models.JSONField(default=list)),
                ('conflicts', models.JSONField(default=list)),
                ('obsoletes', models.JSONField(default=list)),
                ('suggests', models.JSONField(default=list)),
                ('enhances', models.JSONField(default=list)),
                ('recommends', models.JSONField(default=list)),
                ('supplements', models.JSONField(default=list)),
                ('location_base', models.TextField()),
                ('location_href', models.TextField()),
                ('rpm_buildhost', models.TextField()),
                ('rpm_group', models.TextField()),
                ('rpm_license', models.TextField()),
                ('rpm_packager', models.TextField()),
                ('rpm_sourcerpm', models.TextField()),
                ('rpm_vendor', models.TextField()),
                ('rpm_header_start', models.BigIntegerField(null=True)),
                ('rpm_header_end', models.BigIntegerField(null=True)),
                ('is_modular', models.BooleanField(default=False)),
                ('size_archive', models.BigIntegerField(null=True)),
                ('size_installed', models.BigIntegerField(null=True)),
                ('size_package', models.BigIntegerField(null=True)),
                ('time_build', models.BigIntegerField(null=True)),
                ('time_file', models.BigIntegerField(null=True)),
                ('_pulp_domain', models.ForeignKey(default=pulpcore.app.util.get_domain_pk, on_delete=django.db.models.deletion.PROTECT, to='core.domain')),
            ],
            options={
                'default_related_name': '%(app_label)s_%(model_name)s',
                'unique_together': {('_pulp_domain', 'name', 'epoch', 'version', 'release', 'arch', 'checksum_type', 'pkgId')},
            },
            bases=('core.content',),
        ),
        migrations.CreateModel(
            name='UpdateRecord',
            fields=[
                ('content_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='core.content')),
                ('id', models.TextField(db_index=True)),
                ('updated_date', models.TextField(null=True)),
                ('description', models.TextField()),
                ('issued_date', models.TextField()),
                ('fromstr', models.TextField()),
                ('status', models.TextField()),
                ('title', models.TextField()),
                ('summary', models.TextField()),
                ('version', models.TextField()),
                ('type', models.TextField()),
                ('severity', models.TextField()),
                ('solution', models.TextField()),
                ('release', models.TextField()),
                ('rights', models.TextField()),
                ('pushcount', models.TextField(blank=True)),
                ('digest', models.TextField(db_index=True)),
                ('reboot_suggested', models.BooleanField(default=False)),
                ('_pulp_domain', models.ForeignKey(default=pulpcore.app.util.get_domain_pk, on_delete=django.db.models.deletion.PROTECT, to='core.domain')),
            ],
            options={
                'default_related_name': '%(app_label)s_%(model_name)s',
                'unique_together': {('_pulp_domain', 'digest')},
            },
            bases=('core.content',),
        ),
        migrations.CreateModel(
            name='PackageGroup',
            fields=[
                ('content_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='core.content')),
                ('id', models.TextField()),
                ('default', models.BooleanField(default=False)),
                ('user_visible', models.BooleanField(default=False)),
                ('display_order', models.IntegerField(null=True)),
                ('name', models.TextField()),
                ('description', models.TextField(default='')),
                ('packages', models.JSONField(default=list)),
                ('biarch_only', models.BooleanField(default=False)),
                ('desc_by_lang', models.JSONField(default=dict)),
                ('name_by_lang', models.JSONField(default=dict)),
                ('digest', models.TextField(db_index=True)),
                ('_pulp_domain', models.ForeignKey(default=pulpcore.app.util.get_domain_pk, on_delete=django.db.models.deletion.PROTECT, to='core.domain')),
            ],
            options={
                'default_related_name': '%(app_label)s_%(model_name)s',
                'unique_together': {('_pulp_domain', 'digest')},
            },
            bases=('core.content',),
        ),
        migrations.CreateModel(
            name='UpdateCollection',
            fields=[
                ('pulp_id', models.UUIDField(default=pulpcore.app.models.base.pulp_uuid, editable=False, primary_key=True, serialize=False)),
                ('pulp_created', models.DateTimeField(auto_now_add=True)),
                ('pulp_last_updated', models.DateTimeField(auto_now=True, null=True)),
                ('name', models.TextField(null=True)),
                ('shortname', models.TextField(null=True)),
                ('module', models.JSONField(null=True)),
                ('update_record', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='collections', to='rpm.updaterecord')),
            ],
            options={
                'abstract': False,
                'unique_together': {('name', 'update_record')},
            },
        ),
        migrations.CreateModel(
            name='Checksum',
            fields=[
                ('pulp_id', models.UUIDField(default=pulpcore.app.models.base.pulp_uuid, editable=False, primary_key=True, serialize=False)),
                ('pulp_created', models.DateTimeField(auto_now_add=True)),
                ('pulp_last_updated', models.DateTimeField(auto_now=True, null=True)),
                ('path', models.TextField()),
                ('checksum', models.TextField()),
                ('distribution_tree', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='checksums', to='rpm.distributiontree')),
            ],
            options={
                'unique_together': {('path', 'checksum', 'distribution_tree')},
            },
        ),
        migrations.CreateModel(
            name='Image',
            fields=[
                ('pulp_id', models.UUIDField(default=pulpcore.app.models.base.pulp_uuid, editable=False, primary_key=True, serialize=False)),
                ('pulp_created', models.DateTimeField(auto_now_add=True)),
                ('pulp_last_updated', models.DateTimeField(auto_now=True, null=True)),
                ('name', models.TextField()),
                ('path', models.TextField()),
                ('platforms', models.TextField()),
                ('distribution_tree', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='images', to='rpm.distributiontree')),
            ],
            options={
                'unique_together': {('name', 'path', 'platforms', 'distribution_tree')},
            },
        ),
        migrations.CreateModel(
            name='RpmAlternateContentSource',
            fields=[
                ('alternatecontentsource_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='core.alternatecontentsource')),
            ],
            options={
                'default_related_name': '%(app_label)s_%(model_name)s',
                'permissions': [('refresh_rpmalternatecontentsource', 'Refresh an Alternate Content Source'), ('manage_roles_rpmalternatecontentsource', 'Can manage roles on ACS')],
            },
            bases=('core.alternatecontentsource',),
        ),
        migrations.CreateModel(
            name='RpmRemote',
            fields=[
                ('remote_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='core.remote')),
                ('sles_auth_token', models.TextField(null=True)),
            ],
            options={
                'default_related_name': '%(app_label)s_%(model_name)s',
                'permissions': [('manage_roles_rpmremote', 'Can manage roles on an RPM remotes')],
            },
            bases=('core.remote',),
        ),
        migrations.CreateModel(
            name='UlnRemote',
            fields=[
                ('remote_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='core.remote')),
                ('uln_server_base_url', models.TextField(null=True)),
            ],
            options={
                'default_related_name': '%(app_label)s_%(model_name)s',
                'permissions': [('manage_roles_ulnremote', 'Can manage roles on an ULN remotes')],
            },
            bases=('core.remote',),
        ),
        migrations.CreateModel(
            name='UpdateCollectionPackage',
            fields=[
                ('pulp_id', models.UUIDField(default=pulpcore.app.models.base.pulp_uuid, editable=False, primary_key=True, serialize=False)),
                ('pulp_created', models.DateTimeField(auto_now_add=True)),
                ('pulp_last_updated', models.DateTimeField(auto_now=True, null=True)),
                ('arch', models.TextField()),
                ('epoch', models.TextField()),
                ('filename', models.TextField()),
                ('name', models.TextField()),
                ('reboot_suggested', models.BooleanField(default=False)),
                ('release', models.TextField()),
                ('src', models.TextField()),
                ('sum', models.TextField()),
                ('version', models.TextField()),
                ('update_collection', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='packages', to='rpm.updatecollection')),
                ('relogin_suggested', models.BooleanField(default=False)),
                ('restart_suggested', models.BooleanField(default=False)),
                ('sum_type', models.PositiveIntegerField(choices=[(0, 0), (1, 1), (2, 2), (3, 3), (4, 4), (5, 5), (6, 6), (7, 7)], default=None, null=True)),
            ],
            options={
                'abstract': False,
            },
        ),
        migrations.CreateModel(
            name='UpdateReference',
            fields=[
                ('pulp_id', models.UUIDField(default=pulpcore.app.models.base.pulp_uuid, editable=False, primary_key=True, serialize=False)),
                ('pulp_created', models.DateTimeField(auto_now_add=True)),
                ('pulp_last_updated', models.DateTimeField(auto_now=True, null=True)),
                ('href', models.TextField()),
                ('ref_id', models.TextField(null=True)),
                ('title', models.TextField(null=True)),
                ('ref_type', models.TextField()),
                ('update_record', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='references', to='rpm.updaterecord')),
            ],
            options={
                'abstract': False,
            },
        ),
        migrations.CreateModel(
            name='ModulemdDefaults',
            fields=[
                ('content_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='core.content')),
                ('module', models.TextField()),
                ('stream', models.TextField()),
                ('profiles', models.JSONField(default=list)),
                ('digest', models.TextField(db_index=True)),
                ('snippet', models.TextField()),
                ('_pulp_domain', models.ForeignKey(default=pulpcore.app.util.get_domain_pk, on_delete=django.db.models.deletion.PROTECT, to='core.domain')),
            ],
            options={
                'default_related_name': '%(app_label)s_%(model_name)s',
                'unique_together': {('_pulp_domain', 'digest')},
            },
            bases=('core.content',),
        ),
        migrations.CreateModel(
            name='ModulemdObsolete',
            fields=[
                ('content_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='core.content')),
                ('modified', models.TextField()),
                ('module_name', models.TextField()),
                ('module_stream', models.TextField()),
                ('message', models.TextField()),
                ('override_previous', models.BooleanField(null=True)),
                ('module_context', models.TextField(null=True)),
                ('eol_date', models.TextField(null=True)),
                ('obsoleted_by_module_name', models.TextField(null=True)),
                ('obsoleted_by_module_stream', models.TextField(null=True)),
                ('snippet', models.TextField()),
                ('_pulp_domain', models.ForeignKey(default=pulpcore.app.util.get_domain_pk, on_delete=django.db.models.deletion.PROTECT, to='core.domain')),
            ],
            options={
                'default_related_name': '%(app_label)s_%(model_name)s',
                'unique_together': {('_pulp_domain', 'modified', 'module_name', 'module_stream')},
            },
            bases=('core.content',),
        ),
        migrations.CreateModel(
            name='PackageCategory',
            fields=[
                ('content_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='core.content')),
                ('id', models.TextField()),
                ('name', models.TextField()),
                ('description', models.TextField(default='')),
                ('display_order', models.IntegerField(null=True)),
                ('group_ids', models.JSONField(default=list)),
                ('desc_by_lang', models.JSONField(default=dict)),
                ('name_by_lang', models.JSONField(default=dict)),
                ('digest', models.TextField(db_index=True)),
                ('_pulp_domain', models.ForeignKey(default=pulpcore.app.util.get_domain_pk, on_delete=django.db.models.deletion.PROTECT, to='core.domain')),
            ],
            options={
                'default_related_name': '%(app_label)s_%(model_name)s',
                'unique_together': {('_pulp_domain', 'digest')},
            },
            bases=('core.content',),
        ),
        migrations.CreateModel(
            name='PackageEnvironment',
            fields=[
                ('content_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='core.content')),
                ('id', models.TextField()),
                ('name', models.TextField()),
                ('description', models.TextField(default='')),
                ('display_order', models.IntegerField(null=True)),
                ('group_ids', models.JSONField(default=list)),
                ('option_ids', models.JSONField(default=list)),
                ('desc_by_lang', models.JSONField(default=dict)),
                ('name_by_lang', models.JSONField(default=dict)),
                ('digest', models.TextField(db_index=True)),
                ('_pulp_domain', models.ForeignKey(default=pulpcore.app.util.get_domain_pk, on_delete=django.db.models.deletion.PROTECT, to='core.domain')),
            ],
            options={
                'default_related_name': '%(app_label)s_%(model_name)s',
                'unique_together': {('_pulp_domain', 'digest')},
            },
            bases=('core.content',),
        ),
        migrations.CreateModel(
            name='PackageLangpacks',
            fields=[
                ('content_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='core.content')),
                ('matches', models.JSONField(default=dict)),
                ('digest', models.TextField(db_index=True)),
                ('_pulp_domain', models.ForeignKey(default=pulpcore.app.util.get_domain_pk, on_delete=django.db.models.deletion.PROTECT, to='core.domain')),
            ],
            options={
                'default_related_name': '%(app_label)s_%(model_name)s',
                'unique_together': {('_pulp_domain', 'digest')},
            },
            bases=('core.content',),
        ),
        migrations.CreateModel(
            name='RepoMetadataFile',
            fields=[
                ('content_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='core.content')),
                ('data_type', models.TextField()),
                ('checksum_type', models.TextField(choices=[('unknown', 'unknown'), ('md5', 'md5'), ('sha1', 'sha1'), ('sha1', 'sha1'), ('sha224', 'sha224'), ('sha256', 'sha256'), ('sha384', 'sha384'), ('sha512', 'sha512')])),
                ('checksum', models.TextField()),
                ('relative_path', models.TextField()),
                ('_pulp_domain', models.ForeignKey(default=pulpcore.app.util.get_domain_pk, on_delete=django.db.models.deletion.PROTECT, to='core.domain')),
            ],
            options={
                'default_related_name': '%(app_label)s_%(model_name)s',
                'unique_together': {('_pulp_domain', 'data_type', 'checksum', 'relative_path')},
            },
            bases=('core.content',),
        ),
        migrations.CreateModel(
            name='Modulemd',
            fields=[
                ('content_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='core.content')),
                ('name', models.TextField()),
                ('stream', models.TextField()),
                ('version', models.TextField()),
                ('context', models.TextField()),
                ('arch', models.TextField()),
                ('dependencies', models.JSONField(default=list)),
                ('artifacts', models.JSONField(default=list)),
                ('packages', models.ManyToManyField(to='rpm.package')),
                ('static_context', models.BooleanField(null=True)),
                ('snippet', models.TextField()),
                ('description', models.TextField()),
                ('profiles', models.JSONField(default=dict)),
                ('_pulp_domain', models.ForeignKey(default=pulpcore.app.util.get_domain_pk, on_delete=django.db.models.deletion.PROTECT, to='core.domain')),
                ('digest', models.TextField()),
            ],
            options={
                'default_related_name': '%(app_label)s_%(model_name)s',
                'unique_together': {('_pulp_domain', 'name', 'stream', 'version', 'context', 'arch', 'digest')},
            },
            bases=('core.content',),
        ),
        migrations.CreateModel(
            name='RpmDistribution',
            fields=[
                ('distribution_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='core.distribution')),
                ('generate_repo_config', models.BooleanField(default=False)),
            ],
            options={
                'default_related_name': '%(app_label)s_%(model_name)s',
                'permissions': [('manage_roles_rpmdistribution', 'Can manage roles on an RPM distribution')],
            },
            bases=('core.distribution',),
        ),
        migrations.CreateModel(
            name='Addon',
            fields=[
                ('pulp_id', models.UUIDField(default=pulpcore.app.models.base.pulp_uuid, editable=False, primary_key=True, serialize=False)),
                ('pulp_created', models.DateTimeField(auto_now_add=True)),
                ('pulp_last_updated', models.DateTimeField(auto_now=True, null=True)),
                ('addon_id', models.TextField()),
                ('uid', models.TextField()),
                ('name', models.TextField()),
                ('type', models.TextField()),
                ('packages', models.TextField()),
                ('distribution_tree', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='addons', to='rpm.distributiontree')),
                ('repository', models.ForeignKey(on_delete=django.db.models.deletion.RESTRICT, related_name='addons', to='core.repository')),
            ],
            options={
                'unique_together': {('addon_id', 'uid', 'name', 'type', 'packages', 'distribution_tree')},
            },
        ),
        migrations.CreateModel(
            name='Variant',
            fields=[
                ('pulp_id', models.UUIDField(default=pulpcore.app.models.base.pulp_uuid, editable=False, primary_key=True, serialize=False)),
                ('pulp_created', models.DateTimeField(auto_now_add=True)),
                ('pulp_last_updated', models.DateTimeField(auto_now=True, null=True)),
                ('variant_id', models.TextField()),
                ('uid', models.TextField()),
                ('name', models.TextField()),
                ('type', models.TextField()),
                ('packages', models.TextField()),
                ('source_packages', models.TextField(null=True)),
                ('source_repository', models.TextField(null=True)),
                ('debug_packages', models.TextField(null=True)),
                ('debug_repository', models.TextField(null=True)),
                ('identity', models.TextField(null=True)),
                ('distribution_tree', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='variants', to='rpm.distributiontree')),
                ('repository', models.ForeignKey(null=True, on_delete=django.db.models.deletion.RESTRICT, related_name='variants', to='core.repository')),
            ],
            options={
                'unique_together': {('variant_id', 'uid', 'name', 'type', 'packages', 'distribution_tree')},
            },
        ),
        migrations.CreateModel(
            name='RpmPublication',
            fields=[
                ('publication_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='core.publication')),
                ('metadata_checksum_type', models.TextField(choices=[('unknown', 'unknown'), ('md5', 'md5'), ('sha1', 'sha1'), ('sha1', 'sha1'), ('sha224', 'sha224'), ('sha256', 'sha256'), ('sha384', 'sha384'), ('sha512', 'sha512')])),
                ('package_checksum_type', models.TextField(choices=[('unknown', 'unknown'), ('md5', 'md5'), ('sha1', 'sha1'), ('sha1', 'sha1'), ('sha224', 'sha224'), ('sha256', 'sha256'), ('sha384', 'sha384'), ('sha512', 'sha512')])),
                ('repo_config', models.JSONField(default=dict)),
                ('checksum_type', models.TextField(choices=[('unknown', 'unknown'), ('md5', 'md5'), ('sha1', 'sha1'), ('sha1', 'sha1'), ('sha224', 'sha224'), ('sha256', 'sha256'), ('sha384', 'sha384'), ('sha512', 'sha512')])),
                ('compression_type', models.TextField(choices=[('zstd', 'zstd'), ('gz', 'gz')], null=True)),
            ],
            options={
                'default_related_name': '%(app_label)s_%(model_name)s',
                'permissions': [('manage_roles_rpmpublication', 'Can manage roles on an RPM publication')],
            },
            bases=('core.publication',),
        ),
        migrations.CreateModel(
            name='RpmPackageSigningService',
            fields=[
                ('signingservice_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='core.signingservice')),
            ],
            options={
                'abstract': False,
            },
            bases=('core.signingservice',),
        ),
        migrations.CreateModel(
            name='RpmRepository',
            fields=[
                ('repository_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='core.repository')),
                ('metadata_signing_service', models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, to='core.asciiarmoreddetachedsigningservice')),
                ('original_checksum_types', models.JSONField(default=dict)),
                ('retain_package_versions', models.PositiveIntegerField(default=0)),
                ('autopublish', models.BooleanField(default=False)),
                ('metadata_checksum_type', models.TextField(choices=[('unknown', 'unknown'), ('md5', 'md5'), ('sha1', 'sha1'), ('sha1', 'sha1'), ('sha224', 'sha224'), ('sha256', 'sha256'), ('sha384', 'sha384'), ('sha512', 'sha512')], null=True)),
                ('package_checksum_type', models.TextField(choices=[('unknown', 'unknown'), ('md5', 'md5'), ('sha1', 'sha1'), ('sha1', 'sha1'), ('sha224', 'sha224'), ('sha256', 'sha256'), ('sha384', 'sha384'), ('sha512', 'sha512')], null=True)),
                ('last_sync_details', models.JSONField(default=dict)),
                ('repo_config', models.JSONField(default=dict)),
                ('checksum_type', models.TextField(choices=[('unknown', 'unknown'), ('md5', 'md5'), ('sha1', 'sha1'), ('sha1', 'sha1'), ('sha224', 'sha224'), ('sha256', 'sha256'), ('sha384', 'sha384'), ('sha512', 'sha512')], null=True)),
                ('compression_type', models.TextField(choices=[('zstd', 'zstd'), ('gz', 'gz')], null=True)),
                ('package_signing_fingerprint', models.TextField(max_length=40, null=True)),
                ('package_signing_service', models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, to='rpm.rpmpackagesigningservice')),
            ],
            options={
                'default_related_name': '%(app_label)s_%(model_name)s',
                'permissions': [('manage_roles_rpmrepository', 'Can manage roles on RPM repositories'), ('modify_content_rpmrepository', 'Add content to, or remove content from a repository'), ('repair_rpmrepository', 'Copy a repository'), ('sync_rpmrepository', 'Sync a repository'), ('delete_rpmrepository_version', 'Delete a repository version')],
            },
            bases=('core.repository',),
        ),
        migrations.RunSQL(
            sql="\ncreate type pulp_evr_array_item as (\n  n       NUMERIC,\n  s       TEXT\n);\n\ncreate type pulp_evr_t as (\n  epoch INT,\n  version pulp_evr_array_item[],\n  release pulp_evr_array_item[]\n);\n\nCREATE OR REPLACE FUNCTION pulp_evr_trigger() RETURNS trigger AS $$\n  BEGIN\n    NEW.evr = (select ROW(coalesce(NEW.epoch::numeric,0),\n                          pulp_rpmver_array(coalesce(NEW.version,'pulp_isempty'))::pulp_evr_array_item[],\n                          pulp_rpmver_array(coalesce(NEW.release,'pulp_isempty'))::pulp_evr_array_item[])::pulp_evr_t);\n    RETURN NEW;\n  END;\n$$ language 'plpgsql';\n\ncreate or replace FUNCTION pulp_isempty(t TEXT)\n  RETURNS BOOLEAN as $$\n  BEGIN\n    return t ~ '^[[:space:]]*$';\n  END;\n$$ language 'plpgsql';\n\ncreate or replace FUNCTION pulp_isalphanum(ch CHAR)\n  RETURNS BOOLEAN as $$\n  BEGIN\n    if ascii(ch) between ascii('a') and ascii('z') or\n      ascii(ch) between ascii('A') and ascii('Z') or\n      ascii(ch) between ascii('0') and ascii('9')\n    then\n      return TRUE;\n    end if;\n    return FALSE;\n  END;\n$$ language 'plpgsql';\n\ncreate or replace function pulp_isdigit(ch CHAR)\n  RETURNS BOOLEAN as $$\n  BEGIN\n    if ascii(ch) between ascii('0') and ascii('9')\n    then\n    return TRUE;\n    end if;\n    return FALSE;\n  END ;\n$$ language 'plpgsql';\n\ncreate or replace FUNCTION pulp_rpmver_array (string1 IN VARCHAR)\n  RETURNS pulp_evr_array_item[] as $$\n  declare\n    str1 VARCHAR := string1;\n    digits VARCHAR(10) := '0123456789';\n    lc_alpha VARCHAR(27) := 'abcdefghijklmnopqrstuvwxyz';\n    uc_alpha VARCHAR(27) := 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';\n    alpha VARCHAR(54) := lc_alpha || uc_alpha;\n    one VARCHAR;\n    isnum BOOLEAN;\n    ver_array pulp_evr_array_item[] := ARRAY[]::pulp_evr_array_item[];\n  BEGIN\n    if str1 is NULL\n    then\n      RAISE EXCEPTION 'VALUE_ERROR.';\n    end if;\n\n    one := str1;\n    <<segment_loop>>\n    while one <> ''\n    loop\n      declare\n        segm1 VARCHAR;\n        segm1_n NUMERIC := 0;\n      begin\n        -- Throw out all non-alphanum characters\n        while one <> '' and not pulp_isalphanum(one)\n        loop\n          one := substr(one, 2);\n        end loop;\n        str1 := one;\n        if str1 <> '' and pulp_isdigit(str1)\n        then\n          str1 := ltrim(str1, digits);\n          isnum := true;\n        else\n          str1 := ltrim(str1, alpha);\n          isnum := false;\n        end if;\n        if str1 <> ''\n        then segm1 := substr(one, 1, length(one) - length(str1));\n        else segm1 := one;\n        end if;\n\n        if segm1 = '' then return ver_array; end if; /* arbitrary */\n        if isnum\n        then\n          segm1 := ltrim(segm1, '0');\n          if segm1 <> '' then segm1_n := segm1::numeric; end if;\n          segm1 := NULL;\n        else\n        end if;\n        ver_array := array_append(ver_array, (segm1_n, segm1)::pulp_evr_array_item);\n        one := str1;\n      end;\n    end loop segment_loop;\n\n    return ver_array;\n  END ;\n$$ language 'plpgsql';\n",
        ),
        migrations.RunSQL(
            sql='\n-- create pulp_evr_t on insert, so it matches the provided E/V/R cols\nCREATE TRIGGER pulp_evr_insert_trigger\n  BEFORE INSERT\n  ON rpm_package\n  FOR EACH ROW\n  EXECUTE PROCEDURE pulp_evr_trigger();\n\n-- create pulp_evr_t on update, so it continues to match the provided E/V/R cols, but only if Something Changed\nCREATE TRIGGER pulp_evr_update_trigger\n  BEFORE UPDATE OF epoch, version, release\n  ON rpm_package\n  FOR EACH ROW\n  WHEN (\n    OLD.epoch IS DISTINCT FROM NEW.epoch OR\n    OLD.version IS DISTINCT FROM NEW.version OR\n    OLD.release IS DISTINCT FROM NEW.release\n  )\n  EXECUTE PROCEDURE pulp_evr_trigger();\n',
        ),
        migrations.AddField(
            model_name='package',
            name='evr',
            field=pulp_rpm.app.models.package.RpmVersionField(),
        ),
        migrations.RunSQL(
            sql='\nupdate rpm_package set evr = (\n  select ROW(coalesce(epoch::numeric,0),\n             pulp_rpmver_array(version)::pulp_evr_array_item[],\n             pulp_rpmver_array(release)::pulp_evr_array_item[])::pulp_evr_t\n  );\n',
        ),
    ]
