# Generated by Django 5.1.1 on 2024-09-25 17:43

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


class Migration(migrations.Migration):

    initial = True

    dependencies = [
        ('users', '0001_initial'),
    ]

    operations = [
        migrations.CreateModel(
            name='Item',
            fields=[
                ('id', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
                ('created_at', models.DateTimeField(auto_now_add=True)),
                ('last_modified_at', models.DateTimeField(auto_now=True)),
                ('name', models.TextField(max_length=2048)),
                ('description', models.TextField(max_length=2048)),
                ('author', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='users.usersettings')),
            ],
            options={
                'abstract': False,
            },
        ),
        migrations.CreateModel(
            name='ItemRelation',
            fields=[
                ('id', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
                ('name', models.TextField(max_length=2048)),
                ('description', models.TextField(max_length=2048)),
                ('created_at', models.DateTimeField(auto_now_add=True)),
                ('last_modified_at', models.DateTimeField(auto_now=True)),
                ('author', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='users.usersettings')),
                ('child', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='parents', to='items.item')),
                ('parent', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='children', to='items.item')),
            ],
            options={
                'abstract': False,
            },
        ),
        migrations.AddField(
            model_name='item',
            name='relations',
            field=models.ManyToManyField(through='items.ItemRelation', to='items.item'),
        ),
        migrations.CreateModel(
            name='ItemType',
            fields=[
                ('id', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
                ('created_at', models.DateTimeField(auto_now_add=True)),
                ('last_modified_at', models.DateTimeField(auto_now=True)),
                ('name', models.TextField(max_length=2048)),
                ('description', models.TextField(max_length=2048)),
                ('author', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='users.usersettings')),
            ],
            options={
                'abstract': False,
            },
        ),
        migrations.AddField(
            model_name='item',
            name='type',
            field=models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='items.itemtype'),
        ),
        migrations.CreateModel(
            name='Property',
            fields=[
                ('id', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
                ('name', models.TextField(max_length=2048)),
                ('description', models.TextField(max_length=2048)),
                ('created_at', models.DateTimeField(auto_now_add=True)),
                ('last_modified_at', models.DateTimeField(auto_now=True)),
                ('type', models.CharField(choices=[('text', 'Text'), ('date', 'Date'), ('datetime', 'Date & time')], default='text', max_length=32)),
                ('author', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='users.usersettings')),
            ],
            options={
                'abstract': False,
            },
        ),
        migrations.CreateModel(
            name='LinkedProperty',
            fields=[
                ('id', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
                ('name', models.TextField(max_length=2048)),
                ('description', models.TextField(max_length=2048)),
                ('created_at', models.DateTimeField(auto_now_add=True)),
                ('last_modified_at', models.DateTimeField(auto_now=True)),
                ('value', models.TextField(max_length=2048)),
                ('author', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='users.usersettings')),
                ('item', models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, related_name='linked_properties', to='items.item')),
                ('property', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='items.property')),
            ],
            options={
                'abstract': False,
            },
        ),
        migrations.AddField(
            model_name='item',
            name='properties',
            field=models.ManyToManyField(related_name='items', through='items.LinkedProperty', to='items.property'),
        ),
        migrations.CreateModel(
            name='RelationProperty',
            fields=[
                ('id', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)),
                ('name', models.TextField(max_length=2048)),
                ('description', models.TextField(max_length=2048)),
                ('created_at', models.DateTimeField(auto_now_add=True)),
                ('last_modified_at', models.DateTimeField(auto_now=True)),
                ('value', models.TextField(max_length=2048)),
                ('author', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='users.usersettings')),
                ('property', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='items.property')),
                ('relation', models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, related_name='relation_properties', to='items.itemrelation')),
            ],
            options={
                'abstract': False,
            },
        ),
        migrations.AddField(
            model_name='itemrelation',
            name='properties',
            field=models.ManyToManyField(related_name='relations', through='items.RelationProperty', to='items.property'),
        ),
    ]
