DROP TRIGGER IF EXISTS qipai_product_storage_event_items_no_delete;
DROP TRIGGER IF EXISTS qipai_product_storage_event_items_no_update;
DROP TRIGGER IF EXISTS qipai_product_storage_events_no_delete;
DROP TRIGGER IF EXISTS qipai_product_storage_events_no_update;

DELETE rp FROM qipai_role_permissions rp
INNER JOIN qipai_permissions p ON p.id = rp.permission_id
WHERE p.code IN ('goods.storage.read', 'goods.storage.manage');

DELETE FROM qipai_permissions
WHERE code IN ('goods.storage.read', 'goods.storage.manage');

DROP TABLE IF EXISTS qipai_product_storage_event_items;
DROP TABLE IF EXISTS qipai_product_storage_events;
DROP TABLE IF EXISTS qipai_product_storage_items;
DROP TABLE IF EXISTS qipai_product_storage_records;

ALTER TABLE qipai_product_order_items
  DROP INDEX uq_qipai_product_order_item_scope_id;

DELETE FROM qipai_schema_migrations WHERE version = '2026081109';
