58 lines
1.8 KiB
Python
58 lines
1.8 KiB
Python
|
|
"""add chapter_cover_intents
|
||
|
|
|
||
|
|
Revision ID: 0006_chapter_cover_intents
|
||
|
|
Revises: 0005_story_image_intents
|
||
|
|
Create Date: 2026-03-19
|
||
|
|
|
||
|
|
"""
|
||
|
|
|
||
|
|
from typing import Sequence, Union
|
||
|
|
|
||
|
|
from alembic import op
|
||
|
|
import sqlalchemy as sa
|
||
|
|
|
||
|
|
|
||
|
|
revision: str = "0006_chapter_cover_intents"
|
||
|
|
down_revision: Union[str, Sequence[str], None] = "0005_story_image_intents"
|
||
|
|
branch_labels: Union[str, Sequence[str], None] = None
|
||
|
|
depends_on: Union[str, Sequence[str], None] = None
|
||
|
|
|
||
|
|
|
||
|
|
def upgrade() -> None:
|
||
|
|
op.create_table(
|
||
|
|
"chapter_cover_intents",
|
||
|
|
sa.Column("id", sa.String(), nullable=False),
|
||
|
|
sa.Column("chapter_id", sa.String(), nullable=False),
|
||
|
|
sa.Column("chapter_version_id", sa.String(), nullable=True),
|
||
|
|
sa.Column("story_ids", sa.JSON(), nullable=True),
|
||
|
|
sa.Column("prompt_brief", sa.Text(), nullable=True),
|
||
|
|
sa.Column("status", sa.String(), nullable=False),
|
||
|
|
sa.Column("asset_id", sa.String(), nullable=True),
|
||
|
|
sa.Column("error", sa.Text(), nullable=True),
|
||
|
|
sa.Column("created_at", sa.DateTime(timezone=True), nullable=True),
|
||
|
|
sa.Column("updated_at", sa.DateTime(timezone=True), nullable=True),
|
||
|
|
sa.ForeignKeyConstraint(["chapter_id"], ["chapters.id"], ondelete="CASCADE"),
|
||
|
|
sa.ForeignKeyConstraint(
|
||
|
|
["chapter_version_id"],
|
||
|
|
["chapter_versions.id"],
|
||
|
|
ondelete="SET NULL",
|
||
|
|
),
|
||
|
|
sa.PrimaryKeyConstraint("id"),
|
||
|
|
if_not_exists=True,
|
||
|
|
)
|
||
|
|
op.create_index(
|
||
|
|
op.f("ix_chapter_cover_intents_chapter_id"),
|
||
|
|
"chapter_cover_intents",
|
||
|
|
["chapter_id"],
|
||
|
|
unique=False,
|
||
|
|
if_not_exists=True,
|
||
|
|
)
|
||
|
|
|
||
|
|
|
||
|
|
def downgrade() -> None:
|
||
|
|
op.drop_index(
|
||
|
|
op.f("ix_chapter_cover_intents_chapter_id"),
|
||
|
|
table_name="chapter_cover_intents",
|
||
|
|
)
|
||
|
|
op.drop_table("chapter_cover_intents")
|