"""empty message

Revision ID: roc_dingo_0021_add_retrieved_time
Revises: roc_dingo_0020_rm_biacurrtablehfr
Create Date: 2022-01-17 15:26:10.806747

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

from poppy.pop.alembic.helpers import \
    create_table, execute, user, drop_table

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


def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.add_column('sbm_log', sa.Column('retrieved_time', postgresql.TIMESTAMP(), nullable=True), schema='pipeline')

    # added by hand
    # fix table permissions
    grant_user_seq = (
        """GRANT USAGE, SELECT
        ON ALL SEQUENCES IN SCHEMA pipeline TO {0}""".format(user)
    )
    execute(grant_user_seq)

    # ### end Alembic commands ###


def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_column('sbm_log', 'retrieved_time', schema='pipeline')
    # ### end Alembic commands ###
