SELECT table_name FROM information_schema.tables
WHERE table_schema = DATABASE() AND table_name IN (
  'qipai_notification_templates', 'qipai_notification_routes',
  'qipai_notification_subscriptions', 'qipai_notification_deliveries',
  'qipai_notification_attempts'
) ORDER BY table_name;
SELECT table_name, index_name FROM information_schema.statistics
WHERE table_schema = DATABASE() AND index_name IN (
  'uq_qipai_notification_template_scope', 'idx_qipai_notification_template_event',
  'uq_qipai_notification_route', 'idx_qipai_notification_route_match',
  'uq_qipai_notification_subscription', 'uq_qipai_notification_delivery_idempotency',
  'idx_qipai_notification_delivery_dispatch', 'idx_qipai_notification_delivery_management',
  'uq_qipai_notification_attempt'
) GROUP BY table_name, index_name ORDER BY table_name, index_name;
SELECT trigger_name FROM information_schema.triggers
WHERE trigger_schema = DATABASE() AND trigger_name IN (
  'qipai_notification_attempts_no_update', 'qipai_notification_attempts_no_delete'
) ORDER BY trigger_name;
SELECT code FROM qipai_permissions
WHERE code IN ('notification.read', 'notification.manage') ORDER BY code;
SELECT COUNT(*) AS assigned_role_permission_count FROM qipai_role_permissions rp
INNER JOIN qipai_roles r ON r.tenant_id = rp.tenant_id AND r.id = rp.role_id
INNER JOIN qipai_permissions p ON p.id = rp.permission_id
WHERE r.code IN ('STORE_ADMIN', 'TENANT_ADMIN', 'PLATFORM_ADMIN')
  AND p.code IN ('notification.read', 'notification.manage');
SELECT version, name FROM qipai_schema_migrations WHERE version = '2026081110';
