Add migration for Game
This commit is contained in:
parent
28b122f7e7
commit
ba1159d67e
40
alembic/versions/20250326_070419_4162d36d_create_game.py
Normal file
40
alembic/versions/20250326_070419_4162d36d_create_game.py
Normal file
@ -0,0 +1,40 @@
|
||||
"""create games table
|
||||
|
||||
Revision ID: b2c3d4e5f6g7
|
||||
Revises:
|
||||
Create Date: 2023-12-21 10:00:00.000000
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
from sqlalchemy.sql import func
|
||||
import uuid
|
||||
|
||||
# revision identifiers
|
||||
revision = 'b2c3d4e5f6g7'
|
||||
down_revision = None
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
def upgrade():
|
||||
op.create_table(
|
||||
'games',
|
||||
sa.Column('id', sa.String(), primary_key=True, default=lambda: str(uuid.uuid4())),
|
||||
sa.Column('title', sa.String(), nullable=False, index=True),
|
||||
sa.Column('description', sa.String(), nullable=True),
|
||||
sa.Column('price', sa.Float(), nullable=False),
|
||||
sa.Column('genre', sa.String(), nullable=True),
|
||||
sa.Column('publisher', sa.String(), nullable=True),
|
||||
sa.Column('release_date', sa.DateTime(), nullable=True),
|
||||
sa.Column('rating', sa.Float(), default=0.0),
|
||||
sa.Column('in_stock', sa.Boolean(), default=True),
|
||||
sa.Column('stock_quantity', sa.Integer(), default=0),
|
||||
sa.Column('created_at', sa.DateTime(), server_default=sa.func.now()),
|
||||
sa.Column('updated_at', sa.DateTime(), server_default=sa.func.now(), onupdate=sa.func.now()),
|
||||
sa.PrimaryKeyConstraint('id')
|
||||
)
|
||||
|
||||
op.create_index('ix_games_title', 'games', ['title'])
|
||||
|
||||
def downgrade():
|
||||
op.drop_index('ix_games_title', 'games')
|
||||
op.drop_table('games')
|
Loading…
x
Reference in New Issue
Block a user