# Generated by Django 4.2.7 on 2026-01-28 23:30

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


class Migration(migrations.Migration):

    initial = True

    dependencies = [
        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
    ]

    operations = [
        migrations.CreateModel(
            name="Batch",
            fields=[
                ("id", models.AutoField(primary_key=True, serialize=False)),
                (
                    "created_at",
                    models.DateTimeField(auto_now_add=True, db_index=True, null=True),
                ),
                (
                    "updated_at",
                    models.DateTimeField(auto_now=True, db_index=True, null=True),
                ),
                ("is_mixture", models.BooleanField(blank=True, null=True)),
                ("batch_number", models.IntegerField(blank=True, null=True)),
                ("comments", models.TextField(blank=True, null=True)),
                ("purity", models.FloatField(blank=True, null=True)),
                ("expiration_date", models.DateTimeField(blank=True, null=True)),
                ("supplier", models.CharField(blank=True, max_length=100, null=True)),
                (
                    "supplier_catalog_number",
                    models.CharField(blank=True, max_length=100, null=True),
                ),
                ("num_containers", models.IntegerField(blank=True, null=True)),
                (
                    "total_initial_amount",
                    models.DecimalField(
                        blank=True, decimal_places=3, max_digits=10, null=True
                    ),
                ),
                (
                    "total_current_amount",
                    models.DecimalField(
                        blank=True, decimal_places=3, max_digits=10, null=True
                    ),
                ),
                ("amount_units", models.CharField(blank=True, max_length=5, null=True)),
                ("is_depleted", models.BooleanField(blank=True, null=True)),
            ],
            options={
                "db_table": "inventory_management__batches",
            },
        ),
        migrations.CreateModel(
            name="Container",
            fields=[
                ("id", models.AutoField(primary_key=True, serialize=False)),
                (
                    "created_at",
                    models.DateTimeField(auto_now_add=True, db_index=True, null=True),
                ),
                (
                    "updated_at",
                    models.DateTimeField(auto_now=True, db_index=True, null=True),
                ),
                ("barcode", models.CharField(blank=True, max_length=100, null=True)),
                ("comments", models.TextField(blank=True, null=True)),
                (
                    "initial_amount",
                    models.DecimalField(
                        blank=True, decimal_places=3, max_digits=10, null=True
                    ),
                ),
                (
                    "current_amount",
                    models.DecimalField(
                        blank=True, decimal_places=3, max_digits=10, null=True
                    ),
                ),
                ("amount_units", models.CharField(blank=True, max_length=5, null=True)),
                ("is_depleted", models.BooleanField(blank=True, null=True)),
                (
                    "batch",
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="containers",
                        to="inventory_management.batch",
                    ),
                ),
            ],
            options={
                "db_table": "inventory_management__containers",
            },
        ),
        migrations.CreateModel(
            name="Substance",
            fields=[
                (
                    "created_at",
                    models.DateTimeField(auto_now_add=True, db_index=True, null=True),
                ),
                (
                    "updated_at",
                    models.DateTimeField(auto_now=True, db_index=True, null=True),
                ),
                (
                    "id",
                    models.CharField(max_length=12, primary_key=True, serialize=False),
                ),
                (
                    "substance_type",
                    models.CharField(blank=True, max_length=15, null=True),
                ),
                ("description", models.TextField(blank=True, null=True)),
                (
                    "common_name",
                    models.CharField(blank=True, max_length=255, null=True),
                ),
                ("iupac_name", models.TextField(blank=True, null=True)),
                ("synonyms", models.JSONField(blank=True, default=list, null=True)),
                ("bcpc", models.CharField(blank=True, max_length=20, null=True)),
                ("cas_number", models.CharField(blank=True, max_length=20, null=True)),
                ("chembl", models.CharField(blank=True, max_length=20, null=True)),
                ("chemspace", models.CharField(blank=True, max_length=20, null=True)),
                ("emolecules", models.CharField(blank=True, max_length=20, null=True)),
                ("enamine", models.TextField(blank=True, null=True)),
                ("pdb", models.CharField(blank=True, max_length=20, null=True)),
                ("ppdb", models.CharField(blank=True, max_length=20, null=True)),
                ("pubchem_cid", models.CharField(blank=True, max_length=20, null=True)),
                ("aflow", models.CharField(blank=True, max_length=20, null=True)),
                ("cod", models.CharField(blank=True, max_length=20, null=True)),
                ("jarvis", models.CharField(blank=True, max_length=20, null=True)),
                (
                    "materials_project",
                    models.CharField(blank=True, max_length=20, null=True),
                ),
                ("oqmd", models.CharField(blank=True, max_length=20, null=True)),
            ],
            options={
                "db_table": "inventory_management__substances",
            },
        ),
        migrations.CreateModel(
            name="UsageLog",
            fields=[
                ("id", models.AutoField(primary_key=True, serialize=False)),
                (
                    "created_at",
                    models.DateTimeField(auto_now_add=True, db_index=True, null=True),
                ),
                (
                    "updated_at",
                    models.DateTimeField(auto_now=True, db_index=True, null=True),
                ),
                (
                    "amount_removed",
                    models.DecimalField(decimal_places=3, max_digits=10),
                ),
                ("comments", models.TextField(blank=True, null=True)),
                (
                    "container",
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="usage_logs",
                        to="inventory_management.container",
                    ),
                ),
                (
                    "user",
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.PROTECT,
                        related_name="usage_logs",
                        to=settings.AUTH_USER_MODEL,
                    ),
                ),
            ],
            options={
                "db_table": "inventory_management__usage_logs",
            },
        ),
        migrations.CreateModel(
            name="StorageLocation",
            fields=[
                ("id", models.AutoField(primary_key=True, serialize=False)),
                (
                    "created_at",
                    models.DateTimeField(auto_now_add=True, db_index=True, null=True),
                ),
                (
                    "updated_at",
                    models.DateTimeField(auto_now=True, db_index=True, null=True),
                ),
                ("name", models.CharField(blank=True, max_length=255, null=True)),
                (
                    "temperature_celsius",
                    models.IntegerField(blank=True, default=20, null=True),
                ),
                ("description", models.TextField(blank=True, null=True)),
                (
                    "parent_location",
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="sub_locations",
                        to="inventory_management.storagelocation",
                    ),
                ),
            ],
            options={
                "db_table": "inventory_management__storage_locations",
            },
        ),
        migrations.CreateModel(
            name="Mixture",
            fields=[
                ("id", models.AutoField(primary_key=True, serialize=False)),
                (
                    "created_at",
                    models.DateTimeField(auto_now_add=True, db_index=True, null=True),
                ),
                (
                    "updated_at",
                    models.DateTimeField(auto_now=True, db_index=True, null=True),
                ),
                (
                    "mixture_type_type",
                    models.CharField(blank=True, max_length=15, null=True),
                ),
                ("description", models.TextField(blank=True, null=True)),
                (
                    "common_name",
                    models.CharField(blank=True, max_length=255, null=True),
                ),
                ("synonyms", models.JSONField(blank=True, default=list, null=True)),
                (
                    "substances",
                    models.ManyToManyField(
                        blank=True,
                        db_table="inventory_management__mixture_components",
                        related_name="mixtures",
                        to="inventory_management.substance",
                    ),
                ),
            ],
            options={
                "db_table": "inventory_management__mixtures",
            },
        ),
        migrations.AddField(
            model_name="container",
            name="location",
            field=models.ForeignKey(
                blank=True,
                null=True,
                on_delete=django.db.models.deletion.SET_NULL,
                related_name="containers",
                to="inventory_management.storagelocation",
            ),
        ),
        migrations.AddField(
            model_name="batch",
            name="mixture",
            field=models.ForeignKey(
                blank=True,
                null=True,
                on_delete=django.db.models.deletion.CASCADE,
                related_name="batches",
                to="inventory_management.mixture",
            ),
        ),
        migrations.AddField(
            model_name="batch",
            name="substance",
            field=models.ForeignKey(
                blank=True,
                null=True,
                on_delete=django.db.models.deletion.CASCADE,
                related_name="batches",
                to="inventory_management.substance",
            ),
        ),
    ]
