mirror of
https://github.com/wowlikon/LibraryAPI.git
synced 2025-12-11 21:30:46 +00:00
add alembic and readme
This commit is contained in:
Binary file not shown.
54
app/migrations/versions/d266fdc61e99_init.py
Normal file
54
app/migrations/versions/d266fdc61e99_init.py
Normal file
@@ -0,0 +1,54 @@
|
||||
"""init
|
||||
|
||||
Revision ID: d266fdc61e99
|
||||
Revises:
|
||||
Create Date: 2025-05-27 18:04:22.279035
|
||||
|
||||
"""
|
||||
from typing import Sequence, Union
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
import sqlmodel
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision: str = 'd266fdc61e99'
|
||||
down_revision: Union[str, None] = None
|
||||
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('author',
|
||||
sa.Column('id', sa.Integer(), nullable=False),
|
||||
sa.Column('name', sqlmodel.sql.sqltypes.AutoString(), nullable=False),
|
||||
sa.PrimaryKeyConstraint('id')
|
||||
)
|
||||
op.create_index(op.f('ix_author_id'), 'author', ['id'], unique=False)
|
||||
op.create_table('book',
|
||||
sa.Column('id', sa.Integer(), nullable=False),
|
||||
sa.Column('title', sqlmodel.sql.sqltypes.AutoString(), nullable=False),
|
||||
sa.Column('description', sqlmodel.sql.sqltypes.AutoString(), nullable=False),
|
||||
sa.PrimaryKeyConstraint('id')
|
||||
)
|
||||
op.create_index(op.f('ix_book_id'), 'book', ['id'], unique=False)
|
||||
op.create_table('authorbooklink',
|
||||
sa.Column('author_id', sa.Integer(), nullable=False),
|
||||
sa.Column('book_id', sa.Integer(), nullable=False),
|
||||
sa.ForeignKeyConstraint(['author_id'], ['author.id'], ),
|
||||
sa.ForeignKeyConstraint(['book_id'], ['book.id'], ),
|
||||
sa.PrimaryKeyConstraint('author_id', 'book_id')
|
||||
)
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.drop_table('authorbooklink')
|
||||
op.drop_index(op.f('ix_book_id'), table_name='book')
|
||||
op.drop_table('book')
|
||||
op.drop_index(op.f('ix_author_id'), table_name='author')
|
||||
op.drop_table('author')
|
||||
# ### end Alembic commands ###
|
||||
Reference in New Issue
Block a user