mirror of
https://github.com/wowlikon/LiB.git
synced 2026-02-04 12:31:09 +00:00
54 lines
1.5 KiB
Python
54 lines
1.5 KiB
Python
"""Genres
|
|
|
|
Revision ID: 9d7a43ac5dfc
|
|
Revises: d266fdc61e99
|
|
Create Date: 2025-06-25 11:24:30.229418
|
|
|
|
"""
|
|
|
|
from typing import Sequence, Union
|
|
|
|
import sqlalchemy as sa
|
|
import sqlmodel
|
|
from alembic import op
|
|
|
|
# revision identifiers, used by Alembic.
|
|
revision: str = "9d7a43ac5dfc"
|
|
down_revision: Union[str, None] = "d266fdc61e99"
|
|
branch_labels: Union[str, Sequence[str], None] = None
|
|
depends_on: Union[str, Sequence[str], None] = None
|
|
|
|
|
|
def upgrade() -> None:
|
|
# ### commands auto generated by Alembic - please adjust! ###
|
|
op.create_table(
|
|
"genre",
|
|
sa.Column("name", sqlmodel.sql.sqltypes.AutoString(), nullable=False),
|
|
sa.Column("id", sa.Integer(), nullable=False),
|
|
sa.PrimaryKeyConstraint("id"),
|
|
)
|
|
op.create_index(op.f("ix_genre_id"), "genre", ["id"], unique=False)
|
|
op.create_table(
|
|
"genrebooklink",
|
|
sa.Column("genre_id", sa.Integer(), nullable=False),
|
|
sa.Column("book_id", sa.Integer(), nullable=False),
|
|
sa.ForeignKeyConstraint(
|
|
["book_id"],
|
|
["book.id"],
|
|
),
|
|
sa.ForeignKeyConstraint(
|
|
["genre_id"],
|
|
["genre.id"],
|
|
),
|
|
sa.PrimaryKeyConstraint("genre_id", "book_id"),
|
|
)
|
|
# ### end Alembic commands ###
|
|
|
|
|
|
def downgrade() -> None:
|
|
# ### commands auto generated by Alembic - please adjust! ###
|
|
op.drop_table("genrebooklink")
|
|
op.drop_index(op.f("ix_genre_id"), table_name="genre")
|
|
op.drop_table("genre")
|
|
# ### end Alembic commands ###
|