Fix ActivityLogs index creation - remove DO block for CONCURRENTLY support

This commit is contained in:
2026-03-07 12:37:46 -05:00
parent f47a544c7a
commit 5202d72999
2 changed files with 31 additions and 15 deletions
+27
View File
@@ -0,0 +1,27 @@
-- ================================================
-- Fix for ActivityLogs Index
-- Run this separately to create the missing index
-- ================================================
--
-- This creates the ActivityLogs index that couldn't be created
-- from within the main migration script due to PostgreSQL
-- limitations with CONCURRENT operations in functions.
--
-- ================================================
-- Create the ActivityLogs index
-- This will error gracefully if the table doesn't exist
CREATE INDEX CONCURRENTLY IF NOT EXISTS idx_activitylogs_userid_datecreated
ON activitylog."ActivityLogs" ("UserId", "DateCreated" DESC)
WHERE "UserId" IS NOT NULL;
-- Verify it was created
SELECT
schemaname AS "Schema",
tablename AS "Table",
indexname AS "Index Name",
indexdef AS "Definition"
FROM pg_indexes
WHERE indexname = 'idx_activitylogs_userid_datecreated';
-- Expected: 1 row showing the index on activitylog.ActivityLogs