# Generated by Django 5.1.7 on 2026-06-03 22:21

import django.db.models.deletion
from django.conf import settings
from django.db import migrations, models


class Migration(migrations.Migration):

    dependencies = [
        ('books', '0001_initial'),
        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
    ]

    operations = [
        migrations.AddField(
            model_name='ebook',
            name='file_size',
            field=models.BigIntegerField(default=0),
        ),
        migrations.AddField(
            model_name='ebook',
            name='format',
            field=models.CharField(blank=True, default='', editable=False, max_length=20),
        ),
        migrations.AddField(
            model_name='ebook',
            name='metadata_json',
            field=models.JSONField(blank=True, default=dict),
        ),
        migrations.AddField(
            model_name='ebook',
            name='page_count',
            field=models.PositiveIntegerField(default=0),
        ),
        migrations.AddField(
            model_name='readingprogress',
            name='device_id',
            field=models.CharField(blank=True, default='', max_length=128),
        ),
        migrations.AddField(
            model_name='readingprogress',
            name='device_name',
            field=models.CharField(blank=True, default='', max_length=128),
        ),
        migrations.AddField(
            model_name='readingprogress',
            name='version',
            field=models.PositiveIntegerField(default=1),
        ),
        migrations.AlterField(
            model_name='ebook',
            name='author',
            field=models.CharField(blank=True, db_index=True, default='', max_length=256),
        ),
        migrations.AlterField(
            model_name='ebook',
            name='title',
            field=models.CharField(db_index=True, max_length=512),
        ),
        migrations.CreateModel(
            name='BookChapter',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('title', models.CharField(max_length=512)),
                ('index', models.IntegerField(default=0)),
                ('href', models.CharField(blank=True, default='', max_length=1024)),
                ('children', models.JSONField(blank=True, default=list)),
                ('ebook', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='chapters', to='books.ebook')),
            ],
            options={
                'verbose_name': 'Book Chapter',
                'verbose_name_plural': 'Book Chapters',
                'db_table': 'books_book_chapter',
                'ordering': ['index'],
            },
        ),
        migrations.CreateModel(
            name='DownloadRecord',
            fields=[
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('file_size', models.BigIntegerField(default=0)),
                ('downloaded_at', models.DateTimeField(auto_now_add=True)),
                ('ebook', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='download_records', to='books.ebook')),
                ('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='download_records', to=settings.AUTH_USER_MODEL)),
            ],
            options={
                'verbose_name': 'Download Record',
                'verbose_name_plural': 'Download Records',
                'db_table': 'books_download_record',
                'ordering': ['-downloaded_at'],
            },
        ),
        migrations.DeleteModel(
            name='ReadingSettings',
        ),
        migrations.AddIndex(
            model_name='bookchapter',
            index=models.Index(fields=['ebook', 'index'], name='books_book__ebook_i_464cd6_idx'),
        ),
        migrations.AlterUniqueTogether(
            name='downloadrecord',
            unique_together={('user', 'ebook')},
        ),
    ]
