# Generated by Django 5.2.12 on 2026-04-18 12:57
# Hand-adjusted so the migration is safe on production DBs that already have the
# hot-patched benchmark cache table.

from django.db import migrations, models


class Migration(migrations.Migration):

    dependencies = [
        ('invest', '0002_remove_transaction_price_per_share_and_more'),
    ]

    operations = [
        migrations.SeparateDatabaseAndState(
            state_operations=[
                migrations.CreateModel(
                    name='BenchmarkPrice',
                    fields=[
                        ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                        ('ticker', models.CharField(max_length=10)),
                        ('date', models.DateField()),
                        ('close', models.DecimalField(decimal_places=4, max_digits=12)),
                    ],
                    options={
                        'ordering': ['ticker', 'date'],
                        'indexes': [models.Index(fields=['ticker', 'date'], name='invest_benc_ticker_17637a_idx')],
                        'unique_together': {('ticker', 'date')},
                    },
                ),
            ],
            database_operations=[
                migrations.RunSQL(
                    sql=(
                        'CREATE TABLE IF NOT EXISTS "invest_benchmarkprice" ('
                        '"id" integer NOT NULL PRIMARY KEY AUTOINCREMENT, '
                        '"ticker" varchar(10) NOT NULL, '
                        '"date" date NOT NULL, '
                        '"close" decimal NOT NULL)'
                    ),
                    reverse_sql='DROP TABLE IF EXISTS "invest_benchmarkprice"',
                ),
                migrations.RunSQL(
                    sql=(
                        'CREATE UNIQUE INDEX IF NOT EXISTS '
                        '"invest_benchmarkprice_ticker_date_uniq" '
                        'ON "invest_benchmarkprice" ("ticker", "date")'
                    ),
                    reverse_sql='DROP INDEX IF EXISTS "invest_benchmarkprice_ticker_date_uniq"',
                ),
                migrations.RunSQL(
                    sql=(
                        'CREATE INDEX IF NOT EXISTS "invest_benc_ticker_17637a_idx" '
                        'ON "invest_benchmarkprice" ("ticker", "date")'
                    ),
                    reverse_sql='DROP INDEX IF EXISTS "invest_benc_ticker_17637a_idx"',
                ),
            ],
        ),
    ]
