🐐
This commit is contained in:
76
backend/alembic/versions/b342602d3eab_initial_schema.py
Normal file
76
backend/alembic/versions/b342602d3eab_initial_schema.py
Normal file
@@ -0,0 +1,76 @@
|
||||
"""initial schema
|
||||
|
||||
Revision ID: b342602d3eab
|
||||
Revises:
|
||||
Create Date: 2026-03-16 15:04:47.516397
|
||||
|
||||
"""
|
||||
from typing import Sequence, Union
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision: str = 'b342602d3eab'
|
||||
down_revision: Union[str, Sequence[str], None] = None
|
||||
branch_labels: Union[str, Sequence[str], None] = None
|
||||
depends_on: Union[str, Sequence[str], None] = None
|
||||
|
||||
|
||||
def upgrade() -> None:
|
||||
"""Upgrade schema."""
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.create_table('users',
|
||||
sa.Column('id', sa.UUID(), nullable=False),
|
||||
sa.Column('username', sa.String(), nullable=False),
|
||||
sa.Column('email', sa.String(), nullable=False),
|
||||
sa.Column('password_hash', sa.String(), nullable=False),
|
||||
sa.Column('created_at', sa.DateTime(), nullable=False),
|
||||
sa.Column('boosters', sa.Integer(), nullable=False),
|
||||
sa.Column('booster_countdown', sa.DateTime(), nullable=False),
|
||||
sa.PrimaryKeyConstraint('id'),
|
||||
sa.UniqueConstraint('email'),
|
||||
sa.UniqueConstraint('username')
|
||||
)
|
||||
op.create_table('cards',
|
||||
sa.Column('id', sa.UUID(), nullable=False),
|
||||
sa.Column('user_id', sa.UUID(), nullable=True),
|
||||
sa.Column('name', sa.String(), nullable=False),
|
||||
sa.Column('image_link', sa.String(), nullable=True),
|
||||
sa.Column('card_rarity', sa.String(), nullable=False),
|
||||
sa.Column('card_type', sa.String(), nullable=False),
|
||||
sa.Column('text', sa.Text(), nullable=True),
|
||||
sa.Column('attack', sa.Integer(), nullable=False),
|
||||
sa.Column('defense', sa.Integer(), nullable=False),
|
||||
sa.Column('cost', sa.Integer(), nullable=False),
|
||||
sa.Column('created_at', sa.DateTime(), nullable=False),
|
||||
sa.ForeignKeyConstraint(['user_id'], ['users.id'], ),
|
||||
sa.PrimaryKeyConstraint('id')
|
||||
)
|
||||
op.create_table('decks',
|
||||
sa.Column('id', sa.UUID(), nullable=False),
|
||||
sa.Column('user_id', sa.UUID(), nullable=False),
|
||||
sa.Column('name', sa.String(), nullable=False),
|
||||
sa.Column('created_at', sa.DateTime(), nullable=False),
|
||||
sa.ForeignKeyConstraint(['user_id'], ['users.id'], ),
|
||||
sa.PrimaryKeyConstraint('id')
|
||||
)
|
||||
op.create_table('deck_cards',
|
||||
sa.Column('deck_id', sa.UUID(), nullable=False),
|
||||
sa.Column('card_id', sa.UUID(), nullable=False),
|
||||
sa.ForeignKeyConstraint(['card_id'], ['cards.id'], ),
|
||||
sa.ForeignKeyConstraint(['deck_id'], ['decks.id'], ),
|
||||
sa.PrimaryKeyConstraint('deck_id', 'card_id')
|
||||
)
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
"""Downgrade schema."""
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.drop_table('deck_cards')
|
||||
op.drop_table('decks')
|
||||
op.drop_table('cards')
|
||||
op.drop_table('users')
|
||||
# ### end Alembic commands ###
|
||||
Reference in New Issue
Block a user