A community based topic aggregation platform built on atproto
1-- +goose Up 2-- +goose StatementBegin 3 4-- Note: The user_maps table is created by GORM's AutoMigrate in the carstore package 5-- Only add indices if the table exists 6DO $$ 7BEGIN 8 -- Check if user_maps table exists 9 IF EXISTS (SELECT 1 FROM information_schema.tables WHERE table_name = 'user_maps') THEN 10 -- Check if column exists before creating index 11 IF EXISTS (SELECT 1 FROM information_schema.columns WHERE table_name = 'user_maps' AND column_name = 'did') THEN 12 -- Explicit column name specified in GORM tag 13 CREATE INDEX IF NOT EXISTS idx_user_maps_did ON user_maps(did); 14 END IF; 15 16 -- Add index on created_at if column exists 17 IF EXISTS (SELECT 1 FROM information_schema.columns WHERE table_name = 'user_maps' AND column_name = 'created_at') THEN 18 CREATE INDEX IF NOT EXISTS idx_user_maps_created_at ON user_maps(created_at); 19 END IF; 20 END IF; 21END $$; 22 23-- +goose StatementEnd 24 25-- +goose Down 26-- +goose StatementBegin 27 28-- Remove indices if they exist 29DROP INDEX IF EXISTS idx_user_maps_did; 30DROP INDEX IF EXISTS idx_user_maps_created_at; 31 32-- +goose StatementEnd