# Generated by Django 5.1.9 on 2025-05-20 16:20

import access.fields
import access.models.tenancy_abstract
import core.models.centurion
import django.db.models.deletion
import django.utils.timezone
from django.conf import settings
from django.db import migrations, models


class Migration(migrations.Migration):

    dependencies = [
        ('access', '0010_company_alter_entity_entity_type_alter_person_dob_and_more'),
        ('contenttypes', '0002_remove_content_type_name'),
        ('core', '0023_ticketcommentaction_alter_manufacturer_organization_and_more'),
        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
    ]

    operations = [
        migrations.CreateModel(
            name='CenturionAudit',
            fields=[
                ('id', models.AutoField(help_text='ID of the item', primary_key=True, serialize=False, unique=True, verbose_name='ID')),
                ('model_notes', models.TextField(blank=True, help_text='Tid bits of information', null=True, verbose_name='Notes')),
                ('created', access.fields.AutoCreatedField(default=django.utils.timezone.now, editable=False, help_text='Date and time of creation', verbose_name='Created')),
                ('before', models.JSONField(blank=True, default=None, help_text='Value before Change', null=True, validators=[core.models.centurion.CenturionModel.validate_field_not_none], verbose_name='Before')),
                ('after', models.JSONField(blank=True, default=None, help_text='Value Change to', null=True, validators=[core.models.centurion.CenturionModel.validate_field_not_none], verbose_name='After')),
                ('action', models.IntegerField(choices=[(1, 'Create'), (2, 'Update'), (3, 'Delete')], default=None, help_text='History action performed', null=True, validators=[core.models.centurion.CenturionModel.validate_field_not_none], verbose_name='Action')),
                ('content_type', models.ForeignKey(blank=True, help_text='Model this history is for', on_delete=django.db.models.deletion.CASCADE, to='contenttypes.contenttype', validators=[core.models.centurion.CenturionModel.validate_field_not_none], verbose_name='Content Model')),
                ('organization', models.ForeignKey(help_text='Tenant this belongs to', on_delete=django.db.models.deletion.CASCADE, related_name='+', to='access.tenant', validators=[access.models.tenancy_abstract.TenancyAbstractModel.validatate_organization_exists], verbose_name='Tenant')),
                ('user', models.ForeignKey(help_text='User whom performed the action', null=True, on_delete=django.db.models.deletion.DO_NOTHING, to=settings.AUTH_USER_MODEL, validators=[core.models.centurion.CenturionModel.validate_field_not_none], verbose_name='User')),
            ],
            options={
                'verbose_name': 'Model History',
                'verbose_name_plural': 'Model Histories',
                'db_table': 'core_audithistory',
                'ordering': ['-created'],
            },
        ),
    ]
