politikorama/migrations/versions/c968d84e9996_.py

66 lines
2.8 KiB
Python

"""empty message
Revision ID: c968d84e9996
Revises: 6a205c6b23bb
Create Date: 2022-05-27 17:56:50.589477
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = 'c968d84e9996'
down_revision = '6a205c6b23bb'
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.create_table('country',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('name', sa.String(length=200), nullable=True),
sa.Column('official_state_name', sa.String(length=200), nullable=True),
sa.Column('alpha_2', sa.String(length=2), nullable=True),
sa.Column('alpha_3', sa.String(length=3), nullable=True),
sa.PrimaryKeyConstraint('id')
)
op.create_table('role',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('name', sa.String(length=200), nullable=True),
sa.PrimaryKeyConstraint('id')
)
op.add_column('membership', sa.Column('source', sa.String(length=200), nullable=True))
op.add_column('membership', sa.Column('reference', sa.String(length=200), nullable=True))
op.add_column('membership', sa.Column('role_id', sa.Integer(), nullable=True))
op.create_foreign_key(None, 'membership', 'role', ['role_id'], ['id'])
op.add_column('representative', sa.Column('birth_date', sa.Date(), nullable=True))
op.add_column('representative', sa.Column('birth_place', sa.String(length=200), nullable=True))
op.add_column('representative', sa.Column('birth_region', sa.String(length=200), nullable=True))
op.add_column('representative', sa.Column('birth_country_id', sa.Integer(), nullable=True))
op.add_column('representative', sa.Column('job', sa.String(length=200), nullable=True))
op.add_column('representative', sa.Column('nationality_id', sa.Integer(), nullable=True))
op.create_foreign_key(None, 'representative', 'country', ['birth_country_id'], ['id'])
op.create_foreign_key(None, 'representative', 'country', ['nationality_id'], ['id'])
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_constraint(None, 'representative', type_='foreignkey')
op.drop_constraint(None, 'representative', type_='foreignkey')
op.drop_column('representative', 'nationality_id')
op.drop_column('representative', 'job')
op.drop_column('representative', 'birth_country_id')
op.drop_column('representative', 'birth_region')
op.drop_column('representative', 'birth_place')
op.drop_column('representative', 'birth_date')
op.drop_constraint(None, 'membership', type_='foreignkey')
op.drop_column('membership', 'role_id')
op.drop_column('membership', 'reference')
op.drop_column('membership', 'source')
op.drop_table('role')
op.drop_table('country')
# ### end Alembic commands ###