35 lines
1.3 KiB
Python
35 lines
1.3 KiB
Python
"""Update the endpoint path and related helper functions, schemas, and models to use the new '/user-books' path instead of '/books'.
|
|
Revision ID: 4c7e4a5c2f98
|
|
Revises: 7a3c9f2e8a5d
|
|
Create Date: 2023-05-23 11:45:23.451164
|
|
"""
|
|
from alembic import op
|
|
import sqlalchemy as sa
|
|
from sqlalchemy.sql import func
|
|
import uuid
|
|
|
|
# revision identifiers, used by Alembic.
|
|
revision = '4c7e4a5c2f98'
|
|
down_revision = '7a3c9f2e8a5d'
|
|
branch_labels = None
|
|
depends_on = None
|
|
|
|
def upgrade():
|
|
table_name = "user_books"
|
|
op.create_table(
|
|
table_name,
|
|
sa.Column('id', sa.String(36), primary_key=True, default=lambda: str(uuid.uuid4())),
|
|
sa.Column('title', sa.String(), nullable=False),
|
|
sa.Column('author', sa.String(), nullable=False),
|
|
sa.Column('description', sa.String(), nullable=True),
|
|
sa.Column('genre', sa.String(), nullable=True),
|
|
sa.Column('pages', sa.Integer(), nullable=True),
|
|
sa.Column('publisher_id', sa.String(36), nullable=True),
|
|
sa.Column('created_at', sa.DateTime(), server_default=func.now()),
|
|
sa.Column('updated_at', sa.DateTime(), server_default=func.now(), onupdate=func.now()),
|
|
sa.ForeignKeyConstraint(['publisher_id'], ['publishers.id'])
|
|
)
|
|
|
|
def downgrade():
|
|
table_name = "user_books"
|
|
op.drop_table(table_name) |