"""Tables for User, Password, Comments, Friends and Posts

Revision ID: 3d6c688278ae
Revises: 
Create Date: 2019-10-08 15:19:44.799296

"""
from alembic import op
import sqlalchemy as sa


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


def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('user',
    sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
    sa.Column('username', sa.String(length=30), nullable=True),
    sa.Column('email', sa.String(length=30), nullable=True),
    sa.Column('password_hash', sa.String(length=128), nullable=True),
    sa.Column('first_name', sa.String(length=30), nullable=True),
    sa.Column('last_name', sa.String(length=30), nullable=True),
    sa.Column('education', sa.String(length=30), nullable=True),
    sa.Column('employment', sa.String(length=30), nullable=True),
    sa.Column('music', sa.String(length=30), nullable=True),
    sa.Column('movie', sa.String(length=30), nullable=True),
    sa.Column('nationality', sa.String(length=30), nullable=True),
    sa.Column('birthday', sa.Date(), nullable=True),
    sa.Column('last_login_try', sa.DateTime(), nullable=True),
    sa.Column('failed_logins', sa.Integer(), nullable=True),
    sa.Column('is_blocked', sa.Boolean(), nullable=True),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_index(op.f('ix_user_email'), 'user', ['email'], unique=True)
    op.create_index(op.f('ix_user_username'), 'user', ['username'], unique=True)
    op.create_table('friends',
    sa.Column('u_id', sa.Integer(), nullable=False),
    sa.Column('f_id', sa.Integer(), nullable=False),
    sa.ForeignKeyConstraint(['f_id'], ['user.id'], ),
    sa.ForeignKeyConstraint(['u_id'], ['user.id'], ),
    sa.PrimaryKeyConstraint('u_id', 'f_id')
    )
    op.create_table('password',
    sa.Column('u_id', sa.Integer(), nullable=False),
    sa.Column('password_hash', sa.String(length=128), nullable=False),
    sa.Column('creation_time', sa.DateTime(), nullable=True),
    sa.ForeignKeyConstraint(['u_id'], ['user.id'], ),
    sa.PrimaryKeyConstraint('u_id', 'password_hash')
    )
    op.create_index(op.f('ix_password_creation_time'), 'password', ['creation_time'], unique=False)
    op.create_table('posts',
    sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
    sa.Column('u_id', sa.Integer(), nullable=True),
    sa.Column('content', sa.Integer(), nullable=True),
    sa.Column('image', sa.String(), nullable=True),
    sa.Column('creation_time', sa.DateTime(), nullable=True),
    sa.ForeignKeyConstraint(['u_id'], ['user.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_index(op.f('ix_posts_creation_time'), 'posts', ['creation_time'], unique=False)
    op.create_table('comments',
    sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
    sa.Column('p_id', sa.Integer(), nullable=True),
    sa.Column('u_id', sa.Integer(), nullable=True),
    sa.Column('comment', sa.String(length=140), nullable=True),
    sa.Column('creation_time', sa.DateTime(), nullable=True),
    sa.ForeignKeyConstraint(['p_id'], ['posts.id'], ),
    sa.ForeignKeyConstraint(['u_id'], ['user.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    # ### end Alembic commands ###


def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_table('comments')
    op.drop_index(op.f('ix_posts_creation_time'), table_name='posts')
    op.drop_table('posts')
    op.drop_index(op.f('ix_password_creation_time'), table_name='password')
    op.drop_table('password')
    op.drop_table('friends')
    op.drop_index(op.f('ix_user_username'), table_name='user')
    op.drop_index(op.f('ix_user_email'), table_name='user')
    op.drop_table('user')
    # ### end Alembic commands ###

"""Tables for User, Password, Comments, Friends and Posts

Revision ID: 3d6c688278ae
Revises: 
Create Date: 2019-10-08 15:19:44.799296

"""
from alembic import op
import sqlalchemy as sa


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


def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('user',
    sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
    sa.Column('username', sa.String(length=30), nullable=True),
    sa.Column('email', sa.String(length=30), nullable=True),
    sa.Column('password_hash', sa.String(length=128), nullable=True),
    sa.Column('first_name', sa.String(length=30), nullable=True),
    sa.Column('last_name', sa.String(length=30), nullable=True),
    sa.Column('education', sa.String(length=30), nullable=True),
    sa.Column('employment', sa.String(length=30), nullable=True),
    sa.Column('music', sa.String(length=30), nullable=True),
    sa.Column('movie', sa.String(length=30), nullable=True),
    sa.Column('nationality', sa.String(length=30), nullable=True),
    sa.Column('birthday', sa.Date(), nullable=True),
    sa.Column('last_login_try', sa.DateTime(), nullable=True),
    sa.Column('failed_logins', sa.Integer(), nullable=True),
    sa.Column('is_blocked', sa.Boolean(), nullable=True),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_index(op.f('ix_user_email'), 'user', ['email'], unique=True)
    op.create_index(op.f('ix_user_username'), 'user', ['username'], unique=True)
    op.create_table('friends',
    sa.Column('u_id', sa.Integer(), nullable=False),
    sa.Column('f_id', sa.Integer(), nullable=False),
    sa.ForeignKeyConstraint(['f_id'], ['user.id'], ),
    sa.ForeignKeyConstraint(['u_id'], ['user.id'], ),
    sa.PrimaryKeyConstraint('u_id', 'f_id')
    )
    op.create_table('password',
    sa.Column('u_id', sa.Integer(), nullable=False),
    sa.Column('password_hash', sa.String(length=128), nullable=False),
    sa.Column('creation_time', sa.DateTime(), nullable=True),
    sa.ForeignKeyConstraint(['u_id'], ['user.id'], ),
    sa.PrimaryKeyConstraint('u_id', 'password_hash')
    )
    op.create_index(op.f('ix_password_creation_time'), 'password', ['creation_time'], unique=False)
    op.create_table('posts',
    sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
    sa.Column('u_id', sa.Integer(), nullable=True),
    sa.Column('content', sa.Integer(), nullable=True),
    sa.Column('image', sa.String(), nullable=True),
    sa.Column('creation_time', sa.DateTime(), nullable=True),
    sa.ForeignKeyConstraint(['u_id'], ['user.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_index(op.f('ix_posts_creation_time'), 'posts', ['creation_time'], unique=False)
    op.create_table('comments',
    sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
    sa.Column('p_id', sa.Integer(), nullable=True),
    sa.Column('u_id', sa.Integer(), nullable=True),
    sa.Column('comment', sa.String(length=140), nullable=True),
    sa.Column('creation_time', sa.DateTime(), nullable=True),
    sa.ForeignKeyConstraint(['p_id'], ['posts.id'], ),
    sa.ForeignKeyConstraint(['u_id'], ['user.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    # ### end Alembic commands ###


def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_table('comments')
    op.drop_index(op.f('ix_posts_creation_time'), table_name='posts')
    op.drop_table('posts')
    op.drop_index(op.f('ix_password_creation_time'), table_name='password')
    op.drop_table('password')
    op.drop_table('friends')
    op.drop_index(op.f('ix_user_username'), table_name='user')
    op.drop_index(op.f('ix_user_email'), table_name='user')
    op.drop_table('user')
    # ### end Alembic commands ###

Tables for User, Password, Comments, Friends and Posts  Revision ID: 3d6c688278ae Revises:  Create Date: 2019-10-08 15:19:44.799296 # revision identifiers, used by Alembic. # ### commands auto generated by Alembic - please adjust! ### # ### end Alembic commands ### # ### commands auto generated by Alembic - please adjust! ### # ### end Alembic commands ###