mirror of
https://github.com/wowlikon/LibraryAPI.git
synced 2025-12-11 21:30:46 +00:00
Created genre table and added links and endpoints for it.
This commit is contained in:
45
migrations/versions/9d7a43ac5dfc_genres.py
Normal file
45
migrations/versions/9d7a43ac5dfc_genres.py
Normal file
@@ -0,0 +1,45 @@
|
||||
"""genres
|
||||
|
||||
Revision ID: 9d7a43ac5dfc
|
||||
Revises: d266fdc61e99
|
||||
Create Date: 2025-06-25 11:24:30.229418
|
||||
|
||||
"""
|
||||
from typing import Sequence, Union
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
import sqlmodel
|
||||
|
||||
|
||||
# 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 ###
|
||||
Reference in New Issue
Block a user