File size: 1,705 Bytes
93d4e5d | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 | -- Check if all RLS optimization indexes exist
-- Returns TRUE if all exist, FALSE if any are missing
SELECT
CASE
WHEN COUNT(*) = 10 THEN TRUE
ELSE FALSE
END AS all_indexes_exist,
COUNT(*) AS indexes_found,
10 AS indexes_expected,
ARRAY_AGG(indexname ORDER BY indexname) AS existing_indexes
FROM pg_indexes
WHERE schemaname = 'public'
AND indexname IN (
'idx_agents_is_public_account_id',
'idx_agents_account_id_is_public',
'idx_projects_is_public_account_id',
'idx_projects_account_id_is_public',
'idx_threads_is_public_account_id',
'idx_threads_account_id_is_public',
'idx_messages_thread_id_created_at',
'idx_file_uploads_account_id_created_at',
'idx_agent_templates_is_public_creator_id',
'idx_credit_ledger_account_id'
);
-- Alternative: Check each index individually
-- Uncomment below to see which specific indexes are missing
/*
SELECT
index_name,
CASE
WHEN EXISTS (
SELECT 1 FROM pg_indexes
WHERE schemaname = 'public'
AND indexname = index_name
) THEN '✓ EXISTS'
ELSE '✗ MISSING'
END AS status
FROM (
VALUES
('idx_agents_is_public_account_id'),
('idx_agents_account_id_is_public'),
('idx_projects_is_public_account_id'),
('idx_projects_account_id_is_public'),
('idx_threads_is_public_account_id'),
('idx_threads_account_id_is_public'),
('idx_messages_thread_id_created_at'),
('idx_file_uploads_account_id_created_at'),
('idx_agent_templates_is_public_creator_id'),
('idx_credit_ledger_account_id')
) AS idx(index_name)
ORDER BY index_name;
*/
|