# Generated migration for adding video support to PropertyReviews model

from django.db import migrations, models


class Migration(migrations.Migration):

    dependencies = [
        ('property', '0002_initial'),
    ]

    operations = [
        # Convert review_image from ImageField to CharField to support Cloudinary identifiers
        migrations.AlterField(
            model_name='propertyreviews',
            name='review_image',
            field=models.CharField(max_length=255, blank=True, null=True, help_text="Cloudinary public_id for image"),
        ),
        
        # Add video field to store Cloudinary public_id
        migrations.AddField(
            model_name='propertyreviews',
            name='review_video',
            field=models.CharField(max_length=255, blank=True, null=True, help_text="Cloudinary public_id for video"),
        ),
        
        # Add video_duration field to store video length in seconds
        migrations.AddField(
            model_name='propertyreviews',
            name='video_duration',
            field=models.PositiveIntegerField(blank=True, null=True, help_text="Video duration in seconds"),
        ),
        
        # Add constraint to ensure only image OR video can be set (mutually exclusive)
        migrations.AddConstraint(
            model_name='propertyreviews',
            constraint=models.CheckConstraint(
                check=(
                    models.Q(review_image__isnull=False, review_video__isnull=True) |
                    models.Q(review_image__isnull=True, review_video__isnull=False) |
                    models.Q(review_image__isnull=True, review_video__isnull=True)
                ),
                name='property_review_image_or_video_not_both'
            ),
        ),
    ]
