"""Add logging information to LicenseTiers and Licenses

Revision ID: 43a9f29fb214
Revises: bb27b5e41854
Create Date: 2025-04-23 05:53:55.682044

"""
from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = '43a9f29fb214'
down_revision = 'bb27b5e41854'
branch_labels = None
depends_on = None


def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    with op.batch_alter_table('license', schema=None) as batch_op:
        batch_op.add_column(sa.Column('created_at', sa.DateTime(), server_default=sa.text('now()'), nullable=True))
        batch_op.add_column(sa.Column('created_by', sa.Integer(), nullable=True))
        batch_op.add_column(sa.Column('updated_at', sa.DateTime(), server_default=sa.text('now()'), nullable=True))
        batch_op.add_column(sa.Column('updated_by', sa.Integer(), nullable=True))
        batch_op.create_foreign_key(None, 'user', ['created_by'], ['id'], referent_schema='public')
        batch_op.create_foreign_key(None, 'user', ['updated_by'], ['id'], referent_schema='public')

    with op.batch_alter_table('license_tier', schema=None) as batch_op:
        batch_op.add_column(sa.Column('created_at', sa.DateTime(), server_default=sa.text('now()'), nullable=True))
        batch_op.add_column(sa.Column('created_by', sa.Integer(), nullable=True))
        batch_op.add_column(sa.Column('updated_at', sa.DateTime(), server_default=sa.text('now()'), nullable=True))
        batch_op.add_column(sa.Column('updated_by', sa.Integer(), nullable=True))
        batch_op.create_foreign_key(None, 'user', ['created_by'], ['id'], referent_schema='public')
        batch_op.create_foreign_key(None, 'user', ['updated_by'], ['id'], referent_schema='public')

    # ### end Alembic commands ###


def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    with op.batch_alter_table('license_tier', schema=None) as batch_op:
        batch_op.drop_constraint(None, type_='foreignkey')
        batch_op.drop_constraint(None, type_='foreignkey')
        batch_op.drop_column('updated_by')
        batch_op.drop_column('updated_at')
        batch_op.drop_column('created_by')
        batch_op.drop_column('created_at')

    with op.batch_alter_table('license', schema=None) as batch_op:
        batch_op.drop_constraint(None, type_='foreignkey')
        batch_op.drop_constraint(None, type_='foreignkey')
        batch_op.drop_constraint(None, type_='foreignkey')
        batch_op.drop_constraint(None, type_='foreignkey')
        batch_op.create_foreign_key('license_tenant_id_fkey', 'tenant', ['tenant_id'], ['id'])
        batch_op.create_foreign_key('license_tier_id_fkey', 'license_tier', ['tier_id'], ['id'])
        batch_op.drop_column('updated_by')
        batch_op.drop_column('updated_at')
        batch_op.drop_column('created_by')
        batch_op.drop_column('created_at')

    # ### end Alembic commands ###
