"""Add Top global render position and clear all per-product positions.

Revision ID: 059
Revises: 058
"""
from alembic import op
import sqlalchemy as sa

revision = "059"
down_revision = "058"
branch_labels = None
depends_on = None


def upgrade() -> None:
    conn = op.get_bind()
    # Add Top perspective
    conn.execute(
        sa.text(
            "INSERT INTO global_render_positions (id, name, rotation_x, rotation_y, rotation_z, is_default, sort_order, created_at, updated_at) "
            "VALUES (gen_random_uuid(), 'Top', -90.0, 0.0, 0.0, false, 5, now(), now())"
        )
    )
    # Remove all per-product render positions (now redundant with global ones)
    conn.execute(sa.text("DELETE FROM product_render_positions"))


def downgrade() -> None:
    conn = op.get_bind()
    conn.execute(sa.text("DELETE FROM global_render_positions WHERE name = 'Top'"))
    # Per-product positions are not restored on downgrade (data was intentionally cleared)
