# Generated by Django 4.2.17 on 2024-12-23 07:36

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


class Migration(migrations.Migration):

    initial = True

    dependencies = []

    operations = [
        migrations.CreateModel(
            name="Category",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                (
                    "add_time",
                    models.DateTimeField(
                        blank=True, null=True, verbose_name="添加时间"
                    ),
                ),
                (
                    "mod_time",
                    models.DateTimeField(
                        blank=True, null=True, verbose_name="修改时间"
                    ),
                ),
                (
                    "display_order",
                    models.IntegerField(blank=True, null=True, verbose_name="显示排序"),
                ),
                ("title", models.CharField(max_length=64, verbose_name="名称")),
            ],
            options={
                "verbose_name": "配置项分类",
                "verbose_name_plural": "配置项分类",
            },
        ),
        migrations.CreateModel(
            name="Config",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                (
                    "add_time",
                    models.DateTimeField(
                        blank=True, null=True, verbose_name="添加时间"
                    ),
                ),
                (
                    "mod_time",
                    models.DateTimeField(
                        blank=True, null=True, verbose_name="修改时间"
                    ),
                ),
                ("enabled", models.BooleanField(null=True, verbose_name="启用")),
                (
                    "enabled_time",
                    models.DateTimeField(
                        blank=True, null=True, verbose_name="启用时间"
                    ),
                ),
                (
                    "disabled_time",
                    models.DateTimeField(
                        blank=True, null=True, verbose_name="禁用时间"
                    ),
                ),
                (
                    "deleted",
                    models.BooleanField(default=False, verbose_name="是否已删除"),
                ),
                (
                    "deleted_time",
                    models.DateTimeField(
                        blank=True, null=True, verbose_name="删除时间"
                    ),
                ),
                ("published", models.BooleanField(null=True, verbose_name="发布")),
                (
                    "published_time",
                    models.DateTimeField(
                        blank=True, null=True, verbose_name="发布时间"
                    ),
                ),
                (
                    "unpublished_time",
                    models.DateTimeField(
                        blank=True, null=True, verbose_name="收回时间"
                    ),
                ),
                ("key", models.CharField(max_length=64, verbose_name="配置项标识")),
                (
                    "description",
                    models.CharField(
                        blank=True, max_length=64, null=True, verbose_name="配置项说明"
                    ),
                ),
                (
                    "type",
                    models.IntegerField(
                        choices=[
                            (10, "YAML格式"),
                            (20, "JSON格式"),
                            (30, "字符串"),
                            (40, "数值型"),
                        ],
                        default=10,
                        verbose_name="内容数据类型",
                    ),
                ),
                (
                    "data_raw",
                    django_safe_fields.fields.SafeTextField(
                        blank=True,
                        help_text="如果设置的值与指定的类型不匹配，将视为NULL。",
                        null=True,
                        verbose_name="配置项数据",
                    ),
                ),
                (
                    "is_valid",
                    models.BooleanField(
                        editable=False,
                        help_text="这里显示的是上一次保存时的数据解析结果。保存时会更新更新该字段。",
                        null=True,
                        verbose_name="数据解析是否正确",
                    ),
                ),
                (
                    "category",
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.SET_NULL,
                        to="django_app_metadata.category",
                        verbose_name="分类",
                    ),
                ),
            ],
            options={
                "verbose_name": "配置项",
                "verbose_name_plural": "配置项",
                "permissions": [("can_export_configs", "允许导出配置项")],
            },
        ),
    ]
