"""CHG rename user_id to owner_id

Revision ID: 6e59d5c2d34b
Revises: 8099d1e3fafb
Create Date: 2022-07-23 11:58:32.441709

"""
from alembic import op

# revision identifiers, used by Alembic.
revision = "6e59d5c2d34b"
down_revision = "8099d1e3fafb"
branch_labels = None
depends_on = None


def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    conn = op.get_bind()
    with conn.begin() as trx:
        conn.execute('ALTER TABLE theia_paste RENAME COLUMN user_id TO owner_id')
        conn.execute('ALTER TABLE late_exception RENAME COLUMN user_id TO owner_id')
        conn.execute('ALTER TABLE theia_paste RENAME INDEX ix_theia_paste_user_id TO ix_theia_paste_owner_id')
        trx.commit()
    # ### end Alembic commands ###


def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    conn = op.get_bind()
    with conn.begin() as trx:
        conn.execute('ALTER TABLE theia_paste RENAME COLUMN owner_id TO user_id')
        conn.execute('ALTER TABLE late_exception RENAME COLUMN owner_id TO user_id')
        conn.execute('ALTER TABLE theia_paste RENAME INDEX ix_theia_paste_owner_id TO ix_theia_paste_user_id')
        trx.commit()
    # ### end Alembic commands ###
