# Generated by Django 4.2.5 on 2023-11-14 01:57

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

import moo.core.models


class Migration(migrations.Migration):

    initial = True

    dependencies = []

    operations = [
        migrations.CreateModel(
            name="Object",
            fields=[
                ("id", models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name="ID")),
                ("name", models.CharField(max_length=255)),
                ("unique_name", models.BooleanField()),
                (
                    "location",
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.SET_NULL,
                        related_name="contents",
                        to="core.object",
                    ),
                ),
            ],
        ),
        migrations.CreateModel(
            name="Permission",
            fields=[
                ("id", models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name="ID")),
                ("name", models.CharField(max_length=255)),
            ],
        ),
        migrations.CreateModel(
            name="Repository",
            fields=[
                ("id", models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name="ID")),
                ("slug", models.SlugField()),
                ("url", moo.core.models.URLField(max_length=255)),
                ("prefix", models.CharField(max_length=255)),
            ],
        ),
        migrations.CreateModel(
            name="Verb",
            fields=[
                ("id", models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name="ID")),
                ("code", models.TextField(blank=True, null=True)),
                ("filename", models.CharField(blank=True, max_length=255, null=True)),
                ("ref", models.CharField(blank=True, max_length=255, null=True)),
                ("ability", models.BooleanField()),
                ("method", models.BooleanField()),
                (
                    "origin",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE, related_name="verbs", to="core.object"
                    ),
                ),
                (
                    "owner",
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.SET_NULL,
                        related_name="+",
                        to="core.object",
                    ),
                ),
                (
                    "repo",
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.SET_NULL,
                        related_name="+",
                        to="core.repository",
                    ),
                ),
            ],
        ),
        migrations.CreateModel(
            name="VerbName",
            fields=[
                ("id", models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name="ID")),
                ("name", models.CharField(max_length=255)),
                (
                    "verb",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE, related_name="names", to="core.verb"
                    ),
                ),
            ],
        ),
        migrations.CreateModel(
            name="Task",
            fields=[
                ("id", models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name="ID")),
                ("verb_name", models.CharField(max_length=255)),
                ("args", models.TextField()),
                ("kwargs", models.TextField()),
                ("created", models.DateTimeField()),
                ("delay", models.IntegerField()),
                ("killed", models.BooleanField(default=False)),
                ("error", models.CharField(blank=True, max_length=255, null=True)),
                ("trace", models.TextField(blank=True, null=True)),
                (
                    "origin",
                    models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name="+", to="core.object"),
                ),
                (
                    "user",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE, related_name="tasks", to="core.object"
                    ),
                ),
            ],
        ),
        migrations.CreateModel(
            name="Relationship",
            fields=[
                ("id", models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name="ID")),
                ("weight", models.IntegerField(default=0)),
                (
                    "child",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE, related_name="parent", to="core.object"
                    ),
                ),
                (
                    "parent",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE, related_name="child", to="core.object"
                    ),
                ),
            ],
            options={
                "unique_together": {("child", "parent")},
            },
        ),
        migrations.CreateModel(
            name="Property",
            fields=[
                ("id", models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name="ID")),
                ("name", models.CharField(max_length=255)),
                ("value", models.TextField(blank=True, null=True)),
                (
                    "type",
                    models.CharField(
                        choices=[("string", "string"), ("python", "python"), ("dynamic", "dynamic")], max_length=255
                    ),
                ),
                (
                    "origin",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE, related_name="properties", to="core.object"
                    ),
                ),
                (
                    "owner",
                    models.ForeignKey(
                        null=True, on_delete=django.db.models.deletion.SET_NULL, related_name="+", to="core.object"
                    ),
                ),
            ],
            options={
                "verbose_name_plural": "properties",
            },
        ),
        migrations.CreateModel(
            name="Player",
            fields=[
                ("id", models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name="ID")),
                ("session_id", models.CharField(blank=True, max_length=255, null=True)),
                ("wizard", models.BooleanField(default=False)),
                ("enabled", models.BooleanField(default=True)),
                ("crypt", models.CharField(blank=True, max_length=255, null=True)),
                ("last_login", models.DateTimeField(null=True)),
                ("last_logout", models.DateTimeField(null=True)),
                (
                    "avatar",
                    models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, to="core.object"),
                ),
            ],
        ),
        migrations.CreateModel(
            name="Observation",
            fields=[
                ("id", models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name="ID")),
                (
                    "object",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE, related_name="observer", to="core.object"
                    ),
                ),
                (
                    "observer",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE, related_name="object", to="core.object"
                    ),
                ),
            ],
        ),
        migrations.AddField(
            model_name="object",
            name="observers",
            field=models.ManyToManyField(
                blank=True, related_name="observing", through="core.Observation", to="core.object"
            ),
        ),
        migrations.AddField(
            model_name="object",
            name="owner",
            field=models.ForeignKey(
                blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name="+", to="core.object"
            ),
        ),
        migrations.AddField(
            model_name="object",
            name="parents",
            field=models.ManyToManyField(
                blank=True, related_name="children", through="core.Relationship", to="core.object"
            ),
        ),
        migrations.CreateModel(
            name="Alias",
            fields=[
                ("id", models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name="ID")),
                ("alias", models.CharField(max_length=255)),
                (
                    "object",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE, related_name="aliases", to="core.object"
                    ),
                ),
            ],
            options={
                "verbose_name_plural": "aliases",
            },
        ),
        migrations.CreateModel(
            name="Access",
            fields=[
                ("id", models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name="ID")),
                ("rule", models.CharField(choices=[("allow", "allow"), ("deny", "deny")], max_length=5)),
                ("type", models.CharField(choices=[("accessor", "accessor"), ("group", "group")], max_length=8)),
                (
                    "group",
                    models.CharField(
                        choices=[("everyone", "everyone"), ("owners", "owners"), ("wizards", "wizards")],
                        max_length=8,
                        null=True,
                    ),
                ),
                ("weight", models.IntegerField(default=0)),
                (
                    "accessor",
                    models.ForeignKey(
                        null=True, on_delete=django.db.models.deletion.CASCADE, related_name="rights", to="core.object"
                    ),
                ),
                (
                    "object",
                    models.ForeignKey(
                        null=True, on_delete=django.db.models.deletion.CASCADE, related_name="acl", to="core.object"
                    ),
                ),
                (
                    "permission",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE, related_name="usage", to="core.permission"
                    ),
                ),
                (
                    "property",
                    models.ForeignKey(
                        null=True, on_delete=django.db.models.deletion.CASCADE, related_name="acl", to="core.property"
                    ),
                ),
                (
                    "verb",
                    models.ForeignKey(
                        null=True, on_delete=django.db.models.deletion.CASCADE, related_name="acl", to="core.verb"
                    ),
                ),
            ],
            options={
                "verbose_name_plural": "access controls",
            },
        ),
    ]
