# Generated by Django 5.1.3 on 2024-12-02 10:04

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


class Migration(migrations.Migration):

    dependencies = [
        ('core', '0006_contact_notes_alter_contact_full_name'),
    ]

    operations = [
        migrations.RemoveConstraint(
            model_name='contact',
            name='base_owner_constraint',
        ),
        migrations.RemoveConstraint(
            model_name='contact',
            name='base_not_self',
        ),
        migrations.AlterUniqueTogether(
            name='contact',
            unique_together=set(),
        ),
        migrations.AddField(
            model_name='contact',
            name='override',
            field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='overridden_by', to='core.contact'),
        ),
        migrations.AddConstraint(
            model_name='contact',
            constraint=models.CheckConstraint(condition=models.Q(('override__isnull', False), ('owner__isnull', True), _negated=True), name='override_owner_constraint', violation_error_message='A contact overriding a base contact must be owned.'),
        ),
        migrations.AddConstraint(
            model_name='contact',
            constraint=models.CheckConstraint(condition=models.Q(('override', models.F('id')), _negated=True), name='override_not_self', violation_error_message='A contact cannot override itself.'),
        ),
        migrations.RemoveField(
            model_name='contact',
            name='base',
        ),
        migrations.AlterUniqueTogether(
            name='contact',
            unique_together={('owner', 'override')},
        ),
    ]
