"""Remove threejs-renderer: reset thumbnail_renderer setting to 'blender'.

CadFiles that were rendered with three.js will be re-rendered on the next
"Regenerate All Thumbnails" admin action.

Revision ID: 033
Revises: 032
Create Date: 2026-03-06
"""
from alembic import op

revision = '033'
down_revision = '032'
branch_labels = None
depends_on = None


def upgrade():
    # Switch any existing 'threejs' renderer setting to 'blender'
    op.execute("""
        UPDATE system_settings
        SET value = 'blender'
        WHERE key = 'thumbnail_renderer' AND value = 'threejs'
    """)

    # Remove obsolete threejs_render_size setting (no longer used)
    op.execute("""
        DELETE FROM system_settings WHERE key = 'threejs_render_size'
    """)


def downgrade():
    op.execute("""
        INSERT INTO system_settings (key, value, updated_at)
        VALUES ('threejs_render_size', '1024', NOW())
        ON CONFLICT (key) DO NOTHING
    """)
