# Generated by Django 4.1.7 on 2023-04-02 17:21

import django.core.validators
from django.db import migrations, models


def create_default_categories(apps, schema_editor):
    ProductCategory = apps.get_model("purchase", "ProductCategory")
    ProductCategory.objects.using(schema_editor.connection.alias).create(
        name="default",
        color_hue=0,
    )


class Migration(migrations.Migration):
    dependencies = [
        ("purchase", "0016_alter_paymentmethod_options"),
    ]

    operations = [
        migrations.CreateModel(
            name="ProductCategory",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                (
                    "created_at",
                    models.DateTimeField(auto_now_add=True, verbose_name="created at"),
                ),
                (
                    "updated_at",
                    models.DateTimeField(auto_now=True, verbose_name="updated at"),
                ),
                (
                    "name",
                    models.CharField(max_length=250, unique=True, verbose_name="name"),
                ),
                (
                    "color_hue",
                    models.PositiveIntegerField(
                        help_text="Color hue in degrees (0-360)",
                        validators=[django.core.validators.MaxValueValidator(360)],
                        verbose_name="color hue",
                    ),
                ),
            ],
            options={
                "abstract": False,
            },
        ),
        migrations.RunPython(
            create_default_categories,
            reverse_code=migrations.RunPython.noop,
        ),
    ]
