DELETE FROM qipai_schema_migrations
WHERE version = '2026062627';

DELETE duplicate_item
FROM qipai_cleaning_settlement_items duplicate_item
INNER JOIN qipai_cleaning_settlement_items retained_item
  ON retained_item.tenant_id = duplicate_item.tenant_id
  AND retained_item.task_id = duplicate_item.task_id
  AND retained_item.id < duplicate_item.id;

ALTER TABLE qipai_cleaning_settlement_items
  DROP FOREIGN KEY fk_qipai_cleaning_settlement_items_cleaner,
  DROP INDEX uq_qipai_cleaning_settlement_item_task_user,
  DROP INDEX idx_qipai_cleaning_settlement_items_cleaner,
  DROP COLUMN cleaner_user_id,
  ADD UNIQUE KEY uq_qipai_cleaning_settlement_item_task (tenant_id, task_id);

DROP TABLE IF EXISTS qipai_cleaning_task_members;
