"""postgres-fixes

Revision ID: 6dd8adb5e1e3
Revises: f9a80ea383cc
Create Date: 2025-04-23 04:40:38.180082

"""
from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = '6dd8adb5e1e3'
down_revision = 'f9a80ea383cc'
branch_labels = None
depends_on = None


def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    if op.get_bind().engine.name == "postgresql":
        op.drop_constraint('analytics_parent_module_version_fkey', 'analytics', type_='foreignkey')
    # op.alter_column('module_provider', 'namespace_id',
    #            existing_type=sa.INTEGER(),
    #            nullable=False)
    # op.alter_column('namespace', 'namespace',
    #            existing_type=sa.VARCHAR(length=128),
    #            nullable=False)
    # op.create_foreign_key('fk_provider_latest_version_id_provider_version_id', 'provider', 'provider_version', ['latest_version_id'], ['id'], onupdate='CASCADE', ondelete='SET NULL', use_alter=True)
    # ### end Alembic commands ###


def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    # op.drop_constraint('fk_provider_latest_version_id_provider_version_id', 'provider', type_='foreignkey')
    # op.alter_column('namespace', 'namespace',
    #            existing_type=sa.VARCHAR(length=128),
    #            nullable=True)
    # op.alter_column('module_provider', 'namespace_id',
    #            existing_type=sa.INTEGER(),
            #    nullable=True)
    op.create_foreign_key('analytics_parent_module_version_fkey', 'analytics', 'module_version', ['parent_module_version'], ['id'], onupdate='CASCADE', ondelete='CASCADE')
    # ### end Alembic commands ###
