# Generated by Django 5.0.2 on 2026-05-23 10:31

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


class Migration(migrations.Migration):

    dependencies = [
        ('products', '0009_article_main_product'),
    ]

    operations = [
        migrations.AlterUniqueTogether(
            name='subproductversion',
            unique_together=set(),
        ),
        migrations.AddField(
            model_name='mainproduct',
            name='distribution',
            field=models.CharField(choices=[('installable', 'Installable application'), ('package', 'Package (external / non-installable)')], default='installable', help_text='Only affects how releases appear on the public site.', max_length=20),
        ),
        migrations.AddField(
            model_name='subproductversion',
            name='main_product',
            field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='versions', to='products.mainproduct'),
        ),
        migrations.AlterField(
            model_name='subproductversion',
            name='sub_product',
            field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='versions', to='products.subproduct'),
        ),
        migrations.AddConstraint(
            model_name='subproductversion',
            constraint=models.CheckConstraint(check=models.Q(models.Q(('main_product__isnull', True), ('sub_product__isnull', False)), models.Q(('main_product__isnull', False), ('sub_product__isnull', True)), _connector='OR'), name='release_version_exactly_one_parent'),
        ),
        migrations.AddConstraint(
            model_name='subproductversion',
            constraint=models.UniqueConstraint(condition=models.Q(('sub_product__isnull', False)), fields=('sub_product', 'version'), name='release_version_unique_sub_product_version'),
        ),
        migrations.AddConstraint(
            model_name='subproductversion',
            constraint=models.UniqueConstraint(condition=models.Q(('main_product__isnull', False)), fields=('main_product', 'version'), name='release_version_unique_main_product_version'),
        ),
    ]
