# Generated by Django 5.2.9 on 2026-01-18 06:27

from django.db import migrations, models


class Migration(migrations.Migration):

    initial = True

    dependencies = []

    operations = [
        migrations.CreateModel(
            name="Currency",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True, primary_key=True, serialize=False, verbose_name="ID"
                    ),
                ),
                (
                    "code",
                    models.CharField(
                        db_index=True,
                        help_text="Currency code (e.g., USD, BTC)",
                        max_length=10,
                        unique=True,
                    ),
                ),
                ("name", models.CharField(help_text="Currency name", max_length=100)),
                (
                    "symbol",
                    models.CharField(
                        blank=True,
                        default="",
                        help_text="Currency symbol (e.g., $, €)",
                        max_length=10,
                    ),
                ),
                (
                    "currency_type",
                    models.CharField(
                        choices=[("fiat", "Fiat"), ("crypto", "Crypto")],
                        default="fiat",
                        help_text="Fiat or cryptocurrency",
                        max_length=10,
                    ),
                ),
                (
                    "decimals",
                    models.PositiveSmallIntegerField(
                        default=2, help_text="Decimal places for display"
                    ),
                ),
                (
                    "is_active",
                    models.BooleanField(
                        default=True, help_text="Whether currency is available for conversion"
                    ),
                ),
                ("created_at", models.DateTimeField(auto_now_add=True)),
                ("updated_at", models.DateTimeField(auto_now=True)),
            ],
            options={
                "verbose_name": "Currency",
                "verbose_name_plural": "Currencies",
                "db_table": "cfg_currency",
                "ordering": ["code"],
            },
        ),
        migrations.CreateModel(
            name="CurrencyRate",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True, primary_key=True, serialize=False, verbose_name="ID"
                    ),
                ),
                (
                    "base_currency",
                    models.CharField(
                        db_index=True, help_text="Base currency code (e.g., KRW)", max_length=10
                    ),
                ),
                (
                    "quote_currency",
                    models.CharField(
                        db_index=True, help_text="Quote currency code (e.g., USD)", max_length=10
                    ),
                ),
                (
                    "rate",
                    models.DecimalField(
                        decimal_places=12,
                        help_text="Exchange rate (1 base = X quote)",
                        max_digits=24,
                    ),
                ),
                (
                    "provider",
                    models.CharField(
                        default="hybrid", help_text="Rate provider source", max_length=50
                    ),
                ),
                (
                    "is_stale",
                    models.BooleanField(
                        default=False, help_text="Manually marked as needing refresh"
                    ),
                ),
                ("created_at", models.DateTimeField(auto_now_add=True)),
                ("updated_at", models.DateTimeField(auto_now=True)),
            ],
            options={
                "verbose_name": "Exchange Rate",
                "verbose_name_plural": "Exchange Rates",
                "db_table": "cfg_currency_rate",
                "ordering": ["base_currency", "quote_currency"],
                "indexes": [
                    models.Index(
                        fields=["base_currency", "quote_currency"],
                        name="cfg_currenc_base_cu_9135e0_idx",
                    ),
                    models.Index(fields=["updated_at"], name="cfg_currenc_updated_17e8aa_idx"),
                ],
                "unique_together": {("base_currency", "quote_currency")},
            },
        ),
    ]
