DELETE FROM qipai_schema_migrations WHERE version = '2026062219';
DELETE rp FROM qipai_role_permissions rp
INNER JOIN qipai_permissions p ON p.id = rp.permission_id
WHERE p.code IN ('device.read', 'device.write');
DELETE FROM qipai_permissions WHERE code IN ('device.read', 'device.write');
DROP TABLE IF EXISTS qipai_device_maintenance_records;
DROP TABLE IF EXISTS qipai_device_alerts;
DROP TABLE IF EXISTS qipai_device_status_snapshots;
DROP TABLE IF EXISTS qipai_device_links;
DROP TABLE IF EXISTS qipai_device_channels;
ALTER TABLE qipai_devices
  DROP INDEX idx_qipai_devices_store_room,
  DROP INDEX uq_qipai_devices_tenant_iccid,
  DROP INDEX idx_qipai_devices_tenant_imei,
  DROP COLUMN maintenance_status,
  DROP COLUMN last_heartbeat_at,
  DROP COLUMN state_snapshot,
  DROP COLUMN capabilities,
  DROP COLUMN signal_strength,
  DROP COLUMN firmware_version,
  DROP COLUMN model,
  DROP COLUMN iccid;
