"""empty message

Revision ID: <KEY>
Revises: 77a61d457456
Create Date: 2020-05-25 00:01:29.210876

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

# revision identifiers, used by Alembic.
revision = '<KEY>'
down_revision = '77a61d457456'
branch_labels = None
depends_on = None


def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_table('role_permission')
    op.drop_table('friend')
    op.drop_table('user')
    op.drop_table('permission')
    op.drop_table('role')
    op.alter_column(
        'comment', 'user_id',
        existing_type=sa.INTEGER(),
        type_=sa.String(),
        existing_nullable=False)
    op.alter_column(
        'image', 'user_id',
        existing_type=sa.INTEGER(),
        type_=sa.String(),
        existing_nullable=False)
    op.alter_column(
        'post', 'user_id',
        existing_type=sa.INTEGER(),
        type_=sa.String(),
        existing_nullable=False)
    op.alter_column(
        'react', 'user_id',
        existing_type=sa.INTEGER(),
        type_=sa.String(),
        existing_nullable=False)
    # ### end Alembic commands ###


def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.alter_column(
        'react', 'user_id',
        existing_type=sa.String(),
        type_=sa.INTEGER(),
        existing_nullable=False)
    op.alter_column(
        'post', 'user_id',
        existing_type=sa.String(),
        type_=sa.INTEGER(),
        existing_nullable=False)
    op.alter_column(
        'image', 'user_id',
        existing_type=sa.String(),
        type_=sa.INTEGER(),
        existing_nullable=False)
    op.alter_column(
        'comment', 'user_id',
        existing_type=sa.String(),
        type_=sa.INTEGER(),
        existing_nullable=False)
    op.create_table(
        'role',
        sa.Column('created_on', postgresql.TIMESTAMP(),
                  autoincrement=False, nullable=True),
        sa.Column('updated_on', postgresql.TIMESTAMP(),
                  autoincrement=False, nullable=True),
        sa.Column('id', sa.INTEGER(), server_default=sa.text(
            "nextval('role_id_seq'::regclass)"), autoincrement=True,
                  nullable=False),
        sa.Column('slug', sa.VARCHAR(), autoincrement=False,
                  nullable=False),
        sa.Column('name', sa.VARCHAR(), autoincrement=False,
                  nullable=False),
        sa.Column('description', sa.VARCHAR(), autoincrement=False,
                  nullable=False),
        sa.PrimaryKeyConstraint('id', name='role_pkey'),
        sa.UniqueConstraint('slug', name='role_slug_key'),
        postgresql_ignore_search_path=False
    )
    op.create_table(
        'permission',
        sa.Column('created_on', postgresql.TIMESTAMP(),
                  autoincrement=False, nullable=True),
        sa.Column('updated_on', postgresql.TIMESTAMP(),
                  autoincrement=False, nullable=True),
        sa.Column('id', sa.INTEGER(), server_default=sa.text(
            "nextval('permission_id_seq'::regclass)"),
                  autoincrement=True, nullable=False),
        sa.Column('slug', sa.VARCHAR(), autoincrement=False,
                  nullable=False),
        sa.Column('name', sa.VARCHAR(), autoincrement=False,
                  nullable=False),
        sa.Column('description', sa.VARCHAR(), autoincrement=False,
                  nullable=False),
        sa.PrimaryKeyConstraint('id', name='permission_pkey'),
        sa.UniqueConstraint('slug', name='permission_slug_key'),
        postgresql_ignore_search_path=False
    )
    op.create_table(
        'user',
        sa.Column('created_on', postgresql.TIMESTAMP(),
                  autoincrement=False, nullable=True),
        sa.Column('updated_on', postgresql.TIMESTAMP(),
                  autoincrement=False, nullable=True),
        sa.Column('id', sa.INTEGER(), autoincrement=True,
                  nullable=False),
        sa.Column('first_name', sa.VARCHAR(), autoincrement=False,
                  nullable=False),
        sa.Column('last_name', sa.VARCHAR(), autoincrement=False,
                  nullable=False),
        sa.Column('email', sa.VARCHAR(), autoincrement=False,
                  nullable=False),
        sa.Column('email_verified', sa.BOOLEAN(),
                  autoincrement=False, nullable=False),
        sa.Column('email_verif_code', sa.VARCHAR(),
                  autoincrement=False, nullable=True),
        sa.Column('email_verif_code_expires_on',
                  postgresql.TIMESTAMP(), autoincrement=False,
                  nullable=True),
        sa.Column('password_reset_code', sa.VARCHAR(),
                  autoincrement=False, nullable=True),
        sa.Column('password_reset_code_expires_on',
                  postgresql.TIMESTAMP(), autoincrement=False,
                  nullable=True),
        sa.Column('phone_number', sa.VARCHAR(), autoincrement=False,
                  nullable=True),
        sa.Column('profile_picture', sa.VARCHAR(),
                  autoincrement=False, nullable=True),
        sa.Column('cover_picture', sa.VARCHAR(),
                  autoincrement=False, nullable=True),
        sa.Column('password', sa.VARCHAR(), autoincrement=False,
                  nullable=False),
        sa.Column('role_id', sa.INTEGER(), autoincrement=False,
                  nullable=False),
        sa.ForeignKeyConstraint(['role_id'], ['role.id'],
                                name='user_role_id_fkey'),
        sa.PrimaryKeyConstraint('id', name='user_pkey'),
        sa.UniqueConstraint('email', name='user_email_key')
    )
    op.create_table(
        'friend',
        sa.Column('id', sa.INTEGER(), autoincrement=True,
                  nullable=False),
        sa.Column('created_on', postgresql.TIMESTAMP(),
                  autoincrement=False, nullable=True),
        sa.Column('updated_on', postgresql.TIMESTAMP(),
                  autoincrement=False, nullable=True),
        sa.Column('requester_id', sa.INTEGER(), autoincrement=False,
                  nullable=False),
        sa.Column('receiver_id', sa.INTEGER(), autoincrement=False,
                  nullable=False),
        sa.Column('is_friend', sa.BOOLEAN(), autoincrement=False,
                  nullable=False),
        sa.PrimaryKeyConstraint('id', name='friend_pkey')
    )
    op.create_table(
        'role_permission',
        sa.Column('role_id', sa.INTEGER(), autoincrement=False,
                  nullable=False),
        sa.Column('permission_id', sa.INTEGER(),
                  autoincrement=False, nullable=False),
        sa.ForeignKeyConstraint(['permission_id'],
                                ['permission.id'],
                                name='role_permission_permission_id_fkey'),
        sa.ForeignKeyConstraint(['role_id'], ['role.id'],
                                name='role_permission_role_id_fkey',
                                ondelete='CASCADE'),
        sa.PrimaryKeyConstraint('role_id', 'permission_id',
                                name='role_permission_pkey')
    )
    # ### end Alembic commands ###

"""empty message

Revision ID: <KEY>
Revises: 77a61d457456
Create Date: 2020-05-25 00:01:29.210876

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

# revision identifiers, used by Alembic.
revision = '<KEY>'
down_revision = '77a61d457456'
branch_labels = None
depends_on = None


def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_table('role_permission')
    op.drop_table('friend')
    op.drop_table('user')
    op.drop_table('permission')
    op.drop_table('role')
    op.alter_column(
        'comment', 'user_id',
        existing_type=sa.INTEGER(),
        type_=sa.String(),
        existing_nullable=False)
    op.alter_column(
        'image', 'user_id',
        existing_type=sa.INTEGER(),
        type_=sa.String(),
        existing_nullable=False)
    op.alter_column(
        'post', 'user_id',
        existing_type=sa.INTEGER(),
        type_=sa.String(),
        existing_nullable=False)
    op.alter_column(
        'react', 'user_id',
        existing_type=sa.INTEGER(),
        type_=sa.String(),
        existing_nullable=False)
    # ### end Alembic commands ###


def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.alter_column(
        'react', 'user_id',
        existing_type=sa.String(),
        type_=sa.INTEGER(),
        existing_nullable=False)
    op.alter_column(
        'post', 'user_id',
        existing_type=sa.String(),
        type_=sa.INTEGER(),
        existing_nullable=False)
    op.alter_column(
        'image', 'user_id',
        existing_type=sa.String(),
        type_=sa.INTEGER(),
        existing_nullable=False)
    op.alter_column(
        'comment', 'user_id',
        existing_type=sa.String(),
        type_=sa.INTEGER(),
        existing_nullable=False)
    op.create_table(
        'role',
        sa.Column('created_on', postgresql.TIMESTAMP(),
                  autoincrement=False, nullable=True),
        sa.Column('updated_on', postgresql.TIMESTAMP(),
                  autoincrement=False, nullable=True),
        sa.Column('id', sa.INTEGER(), server_default=sa.text(
            "nextval('role_id_seq'::regclass)"), autoincrement=True,
                  nullable=False),
        sa.Column('slug', sa.VARCHAR(), autoincrement=False,
                  nullable=False),
        sa.Column('name', sa.VARCHAR(), autoincrement=False,
                  nullable=False),
        sa.Column('description', sa.VARCHAR(), autoincrement=False,
                  nullable=False),
        sa.PrimaryKeyConstraint('id', name='role_pkey'),
        sa.UniqueConstraint('slug', name='role_slug_key'),
        postgresql_ignore_search_path=False
    )
    op.create_table(
        'permission',
        sa.Column('created_on', postgresql.TIMESTAMP(),
                  autoincrement=False, nullable=True),
        sa.Column('updated_on', postgresql.TIMESTAMP(),
                  autoincrement=False, nullable=True),
        sa.Column('id', sa.INTEGER(), server_default=sa.text(
            "nextval('permission_id_seq'::regclass)"),
                  autoincrement=True, nullable=False),
        sa.Column('slug', sa.VARCHAR(), autoincrement=False,
                  nullable=False),
        sa.Column('name', sa.VARCHAR(), autoincrement=False,
                  nullable=False),
        sa.Column('description', sa.VARCHAR(), autoincrement=False,
                  nullable=False),
        sa.PrimaryKeyConstraint('id', name='permission_pkey'),
        sa.UniqueConstraint('slug', name='permission_slug_key'),
        postgresql_ignore_search_path=False
    )
    op.create_table(
        'user',
        sa.Column('created_on', postgresql.TIMESTAMP(),
                  autoincrement=False, nullable=True),
        sa.Column('updated_on', postgresql.TIMESTAMP(),
                  autoincrement=False, nullable=True),
        sa.Column('id', sa.INTEGER(), autoincrement=True,
                  nullable=False),
        sa.Column('first_name', sa.VARCHAR(), autoincrement=False,
                  nullable=False),
        sa.Column('last_name', sa.VARCHAR(), autoincrement=False,
                  nullable=False),
        sa.Column('email', sa.VARCHAR(), autoincrement=False,
                  nullable=False),
        sa.Column('email_verified', sa.BOOLEAN(),
                  autoincrement=False, nullable=False),
        sa.Column('email_verif_code', sa.VARCHAR(),
                  autoincrement=False, nullable=True),
        sa.Column('email_verif_code_expires_on',
                  postgresql.TIMESTAMP(), autoincrement=False,
                  nullable=True),
        sa.Column('password_reset_code', sa.VARCHAR(),
                  autoincrement=False, nullable=True),
        sa.Column('password_reset_code_expires_on',
                  postgresql.TIMESTAMP(), autoincrement=False,
                  nullable=True),
        sa.Column('phone_number', sa.VARCHAR(), autoincrement=False,
                  nullable=True),
        sa.Column('profile_picture', sa.VARCHAR(),
                  autoincrement=False, nullable=True),
        sa.Column('cover_picture', sa.VARCHAR(),
                  autoincrement=False, nullable=True),
        sa.Column('password', sa.VARCHAR(), autoincrement=False,
                  nullable=False),
        sa.Column('role_id', sa.INTEGER(), autoincrement=False,
                  nullable=False),
        sa.ForeignKeyConstraint(['role_id'], ['role.id'],
                                name='user_role_id_fkey'),
        sa.PrimaryKeyConstraint('id', name='user_pkey'),
        sa.UniqueConstraint('email', name='user_email_key')
    )
    op.create_table(
        'friend',
        sa.Column('id', sa.INTEGER(), autoincrement=True,
                  nullable=False),
        sa.Column('created_on', postgresql.TIMESTAMP(),
                  autoincrement=False, nullable=True),
        sa.Column('updated_on', postgresql.TIMESTAMP(),
                  autoincrement=False, nullable=True),
        sa.Column('requester_id', sa.INTEGER(), autoincrement=False,
                  nullable=False),
        sa.Column('receiver_id', sa.INTEGER(), autoincrement=False,
                  nullable=False),
        sa.Column('is_friend', sa.BOOLEAN(), autoincrement=False,
                  nullable=False),
        sa.PrimaryKeyConstraint('id', name='friend_pkey')
    )
    op.create_table(
        'role_permission',
        sa.Column('role_id', sa.INTEGER(), autoincrement=False,
                  nullable=False),
        sa.Column('permission_id', sa.INTEGER(),
                  autoincrement=False, nullable=False),
        sa.ForeignKeyConstraint(['permission_id'],
                                ['permission.id'],
                                name='role_permission_permission_id_fkey'),
        sa.ForeignKeyConstraint(['role_id'], ['role.id'],
                                name='role_permission_role_id_fkey',
                                ondelete='CASCADE'),
        sa.PrimaryKeyConstraint('role_id', 'permission_id',
                                name='role_permission_pkey')
    )
    # ### end Alembic commands ###

empty message  Revision ID: <KEY> Revises: 77a61d457456 Create Date: 2020-05-25 00:01:29.210876 # 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 ###