57 lines
2.2 KiB
Python
57 lines
2.2 KiB
Python
"""empty message
|
|
|
|
Revision ID: 94e765018166
|
|
Revises:
|
|
Create Date: 2021-12-27 19:01:01.913495
|
|
|
|
"""
|
|
from alembic import op
|
|
import sqlalchemy as sa
|
|
|
|
|
|
# revision identifiers, used by Alembic.
|
|
revision = '94e765018166'
|
|
down_revision = None
|
|
branch_labels = None
|
|
depends_on = None
|
|
|
|
|
|
def upgrade():
|
|
# ### commands auto generated by Alembic - please adjust! ###
|
|
op.create_table('trainers',
|
|
sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
|
|
sa.Column('nickname', sa.String(length=20), nullable=False),
|
|
sa.Column('first_name', sa.String(length=30), nullable=False),
|
|
sa.Column('last_name', sa.String(length=30), nullable=False),
|
|
sa.Column('email', sa.String(length=60), nullable=False),
|
|
sa.Column('password', sa.String(length=200), nullable=False),
|
|
sa.Column('team', sa.String(length=10), nullable=False),
|
|
sa.Column('pokemons_owned', sa.Integer(), nullable=True),
|
|
sa.PrimaryKeyConstraint('id')
|
|
)
|
|
op.create_index(op.f('ix_trainers_email'), 'trainers', ['email'], unique=True)
|
|
op.create_index(op.f('ix_trainers_nickname'), 'trainers', ['nickname'], unique=True)
|
|
op.create_table('pokemons_owned',
|
|
sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
|
|
sa.Column('name', sa.Text(length=50), nullable=False),
|
|
sa.Column('level', sa.Integer(), nullable=True),
|
|
sa.Column('pokemon_id', sa.Integer(), nullable=True),
|
|
sa.Column('trainer_id', sa.Integer(), nullable=True),
|
|
sa.ForeignKeyConstraint(['trainer_id'], ['trainers.id'], ),
|
|
sa.PrimaryKeyConstraint('id')
|
|
)
|
|
op.create_index(op.f('ix_pokemons_owned_name'), 'pokemons_owned', ['name'], unique=True)
|
|
op.create_index(op.f('ix_pokemons_owned_trainer_id'), 'pokemons_owned', ['trainer_id'], unique=False)
|
|
# ### end Alembic commands ###
|
|
|
|
|
|
def downgrade():
|
|
# ### commands auto generated by Alembic - please adjust! ###
|
|
op.drop_index(op.f('ix_pokemons_owned_trainer_id'), table_name='pokemons_owned')
|
|
op.drop_index(op.f('ix_pokemons_owned_name'), table_name='pokemons_owned')
|
|
op.drop_table('pokemons_owned')
|
|
op.drop_index(op.f('ix_trainers_nickname'), table_name='trainers')
|
|
op.drop_index(op.f('ix_trainers_email'), table_name='trainers')
|
|
op.drop_table('trainers')
|
|
# ### end Alembic commands ###
|