"""empty message

Revision ID: f21d6297fd7b
Revises: 
Create Date: 2019-08-24 18:06:31.509587

"""
from alembic import op
import sqlalchemy as sa
from sqlalchemy.dialects import postgresql

# revision identifiers, used by Alembic.
revision = 'f21d6297fd7b'
down_revision = None
branch_labels = None
depends_on = None


def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('citizens',
    sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
    sa.Column('import_id', sa.Integer(), nullable=False),
    sa.Column('citizen_id', sa.Integer(), nullable=False),
    sa.Column('town', sa.String(length=256), nullable=False),
    sa.Column('street', sa.String(length=256), nullable=False),
    sa.Column('building', sa.String(length=256), nullable=False),
    sa.Column('apartment', sa.Integer(), nullable=False),
    sa.Column('name', sa.String(length=256), nullable=False),
    sa.Column('birth_date', sa.Date(), nullable=False),
    sa.Column('gender', postgresql.ENUM('female', 'male', name='gender'), nullable=True),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_index('index_1', 'citizens', ['import_id', 'citizen_id'], unique=True)
    op.create_table('related_communications',
    sa.Column('citizen_id', sa.Integer(), nullable=False),
    sa.Column('relative_id', sa.Integer(), nullable=False),
    sa.ForeignKeyConstraint(['citizen_id'], ['citizens.id'], ),
    sa.ForeignKeyConstraint(['relative_id'], ['citizens.id'], ),
    sa.PrimaryKeyConstraint('citizen_id', 'relative_id')
    )
    # ### end Alembic commands ###


def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_table('related_communications')
    op.drop_index('index_1', table_name='citizens')
    op.drop_table('citizens')
    # ### end Alembic commands ###
