"""clear_attributes_cache

Revision ID: 0281
Revises: 0280
Create Date: 2025-10-30 08:56:12.178870

"""
from alembic import op
import sqlalchemy as sa
from sqlalchemy.dialects import postgresql


# revision identifiers, used by Alembic.
revision = '0281'
down_revision = '0280'
branch_labels = None
depends_on = None


def upgrade():
    op.execute("""UPDATE cards SET cache_id = uuid_generate_v4() FROM card_attributes WHERE card_attributes.card_id = cards.id AND card_attributes.type_name = 'relationships'""")
    op.execute("""UPDATE card_models SET cache_id = uuid_generate_v4() FROM attribute_groups ag JOIN attributes attr ON attr.group_id = ag.id WHERE ag.id = card_models.attribute_group_id AND attr.type_name = 'relationships'""")
    pass


def downgrade():
    pass
