# Generated by Django 3.2.19 on 2023-05-29 22:04

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


class Migration(migrations.Migration):
    initial = True

    dependencies = [
        ("contenttypes", "0002_remove_content_type_name"),
    ]

    operations = [
        migrations.CreateModel(
            name="Collection",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True, primary_key=True, serialize=False, verbose_name="ID"
                    ),
                ),
                ("mitre_stix_identifier", models.CharField(max_length=255, unique=True)),
                ("name", models.CharField(max_length=255)),
                ("description", models.TextField()),
                ("version", models.CharField(max_length=8)),
                ("applied", models.DateTimeField(auto_now_add=True)),
                ("shortname", models.CharField(max_length=16, unique=True)),
            ],
        ),
        migrations.CreateModel(
            name="Matrix",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True, primary_key=True, serialize=False, verbose_name="ID"
                    ),
                ),
                ("mitre_stix_identifier", models.CharField(max_length=255, unique=True)),
                ("mitre_original_data", models.JSONField()),
                ("created", models.DateTimeField()),
                ("modified", models.DateTimeField()),
                ("deprecated", models.BooleanField(default=False)),
                ("revoked", models.BooleanField(default=False)),
                ("name", models.CharField(max_length=255)),
                ("description", models.TextField(blank=True, null=True)),
                ("mitre_id", models.CharField(max_length=255)),
                ("mitre_url", models.URLField()),
                ("slug", models.CharField(max_length=64)),
                ("platforms", models.JSONField(blank=True, null=True)),
                (
                    "collection",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE, to="mitrembc.collection"
                    ),
                ),
            ],
            options={
                "verbose_name_plural": "matrices",
            },
        ),
        migrations.CreateModel(
            name="Technique",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True, primary_key=True, serialize=False, verbose_name="ID"
                    ),
                ),
                ("mitre_stix_identifier", models.CharField(max_length=255, unique=True)),
                ("mitre_original_data", models.JSONField()),
                ("created", models.DateTimeField()),
                ("modified", models.DateTimeField()),
                ("deprecated", models.BooleanField(default=False)),
                ("revoked", models.BooleanField(default=False)),
                ("name", models.CharField(max_length=255)),
                ("description", models.TextField(blank=True, null=True)),
                ("mitre_id", models.CharField(max_length=255)),
                ("mitre_url", models.URLField()),
                ("kill_chain_phases", models.JSONField(blank=True, null=True)),
                ("external_references", models.JSONField()),
                ("is_subtechnique", models.BooleanField(default=False)),
                ("detection_description", models.TextField(blank=True, null=True)),
                ("platforms", models.JSONField(blank=True, null=True)),
                ("version", models.CharField(max_length=16)),
                ("contributors", models.JSONField(blank=True, null=True)),
                ("permissions_required", models.JSONField(blank=True, null=True)),
                ("system_requirements", models.CharField(blank=True, max_length=512, null=True)),
                ("data_sources", models.JSONField(blank=True, null=True)),
                (
                    "collection",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE, to="mitrembc.collection"
                    ),
                ),
                (
                    "major_technique",
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="subtechniques",
                        to="mitrembc.technique",
                    ),
                ),
            ],
            options={
                "abstract": False,
            },
        ),
        migrations.CreateModel(
            name="Tactic",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True, primary_key=True, serialize=False, verbose_name="ID"
                    ),
                ),
                ("mitre_stix_identifier", models.CharField(max_length=255, unique=True)),
                ("mitre_original_data", models.JSONField()),
                ("created", models.DateTimeField()),
                ("modified", models.DateTimeField()),
                ("deprecated", models.BooleanField(default=False)),
                ("revoked", models.BooleanField(default=False)),
                ("name", models.CharField(max_length=255)),
                ("description", models.TextField(blank=True, null=True)),
                ("mitre_id", models.CharField(max_length=255)),
                ("mitre_url", models.URLField()),
                ("shortname", models.CharField(max_length=255)),
                ("order_weight", models.IntegerField(blank=True, default=0)),
                (
                    "collection",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE, to="mitrembc.collection"
                    ),
                ),
                (
                    "matrix",
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.CASCADE,
                        to="mitrembc.matrix",
                    ),
                ),
                ("techniques", models.ManyToManyField(blank=True, to="mitrembc.Technique")),
            ],
            options={
                "abstract": False,
            },
        ),
        migrations.CreateModel(
            name="Software",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True, primary_key=True, serialize=False, verbose_name="ID"
                    ),
                ),
                ("mitre_stix_identifier", models.CharField(max_length=255, unique=True)),
                ("mitre_original_data", models.JSONField()),
                ("created", models.DateTimeField()),
                ("modified", models.DateTimeField()),
                ("deprecated", models.BooleanField(default=False)),
                ("revoked", models.BooleanField(default=False)),
                ("name", models.CharField(max_length=255)),
                ("description", models.TextField(blank=True, null=True)),
                ("mitre_id", models.CharField(max_length=255)),
                ("mitre_url", models.URLField()),
                (
                    "type",
                    models.CharField(
                        choices=[("tool", "Tool"), ("malware", "Malware")], max_length=7
                    ),
                ),
                ("is_family", models.BooleanField(default=False)),
                ("aliases", models.JSONField(blank=True, null=True)),
                ("platforms", models.JSONField(blank=True, null=True)),
                ("version", models.CharField(max_length=16)),
                ("contributors", models.JSONField(blank=True, null=True)),
                (
                    "collection",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE, to="mitrembc.collection"
                    ),
                ),
            ],
            options={
                "verbose_name_plural": "software",
            },
        ),
        migrations.CreateModel(
            name="Reference",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True, primary_key=True, serialize=False, verbose_name="ID"
                    ),
                ),
                ("mitre_stix_identifier", models.CharField(max_length=255, unique=True)),
                ("mitre_original_data", models.JSONField()),
                ("created", models.DateTimeField()),
                ("modified", models.DateTimeField()),
                ("deprecated", models.BooleanField(default=False)),
                ("revoked", models.BooleanField(default=False)),
                ("description", models.TextField(blank=True, null=True)),
                ("relationship_type", models.CharField(max_length=255)),
                ("source_ref_id", models.PositiveIntegerField(editable=False)),
                ("target_ref_id", models.PositiveIntegerField(editable=False)),
                (
                    "collection",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE, to="mitrembc.collection"
                    ),
                ),
                (
                    "source_ref_content_type",
                    models.ForeignKey(
                        editable=False,
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="+",
                        to="contenttypes.contenttype",
                    ),
                ),
                (
                    "target_ref_content_type",
                    models.ForeignKey(
                        editable=False,
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="+",
                        to="contenttypes.contenttype",
                    ),
                ),
            ],
            options={
                "abstract": False,
            },
        ),
    ]
