# Generated by Django 5.1.1 on 2024-09-15 21:26

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


class Migration(migrations.Migration):
    dependencies = [
        ("bloomerp", "0001_initial"),
    ]

    operations = [
        migrations.CreateModel(
            name="SqlQuery",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                ("name", models.CharField(max_length=255)),
                ("query", models.TextField()),
            ],
            options={
                "verbose_name": "SQL Query",
                "verbose_name_plural": "SQL Queries",
                "db_table": "sql_query",
                "managed": True,
            },
        ),
        migrations.CreateModel(
            name="SqlQueryFilter",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                ("name", models.CharField(max_length=255)),
                ("query", models.TextField()),
                (
                    "filter_type",
                    models.CharField(
                        choices=[
                            ("absolute", "Absolute"),
                            ("integer", "Integer"),
                            ("float", "Float"),
                            ("date", "Date"),
                            ("boolean", "Boolean"),
                            ("string", "String"),
                            ("select", "Select"),
                            ("model_select", "Model Select"),
                        ],
                        default="absolute",
                        max_length=255,
                    ),
                ),
                ("filter_options", models.JSONField(blank=True, null=True)),
            ],
            options={
                "verbose_name": "SQL Query Filter",
                "verbose_name_plural": "SQL Query Filters",
                "db_table": "bloomerp_sql_query_filter",
                "managed": True,
            },
        ),
        migrations.AlterField(
            model_name="file",
            name="file",
            field=models.FileField(upload_to=bloomerp.models.File.upload_to),
        ),
        migrations.CreateModel(
            name="Kpi",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                ("name", models.CharField(max_length=255)),
                ("description", models.TextField(blank=True, null=True)),
                (
                    "output_type",
                    models.CharField(
                        choices=[
                            ("table", "Table"),
                            ("value", "Value"),
                            ("line", "Line chart"),
                            ("bar", "Bar chart"),
                            ("pie", "Pie chart"),
                            ("scatter", "Scatter chart"),
                            ("histogram", "Histogram"),
                        ],
                        max_length=10,
                    ),
                ),
                ("options", models.JSONField(blank=True, null=True)),
                (
                    "query",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        to="bloomerp.sqlquery",
                    ),
                ),
            ],
            options={
                "db_table": "kpi",
                "managed": True,
            },
        ),
        migrations.AddField(
            model_name="sqlquery",
            name="filters",
            field=models.ManyToManyField(blank=True, to="bloomerp.sqlqueryfilter"),
        ),
    ]
