Skip to content

Commit 9e059a6

Browse files
committed
chore: add migration to fix schema creation and update existing SQL files
This commit introduces a new migration that ensures all necessary schemas and extensions exist, fixing potential issues with initial setup. It also updates previous migration files to remove redundant schema and extension creation, and refactors function and table definitions for consistency and compatibility with Supabase's reset behavior. Additionally, indexes are added to optimize query performance across various tables.
1 parent 239a05c commit 9e059a6

File tree

2 files changed

+256
-38
lines changed

2 files changed

+256
-38
lines changed
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
-- This migration fixes any issues that might occur with the pgflow initial migration
2+
-- It ensures all required schemas and extensions exist
3+
4+
-- Ensure pgflow schema exists
5+
do $$
6+
BEGIN
7+
IF NOT EXISTS (SELECT 1 FROM pg_namespace WHERE nspname = 'pgflow') THEN
8+
CREATE SCHEMA "pgflow";
9+
END IF;
10+
END
11+
$$;
12+
13+
-- Ensure pgmq schema exists
14+
do $$
15+
BEGIN
16+
IF NOT EXISTS (SELECT 1 FROM pg_namespace WHERE nspname = 'pgmq') THEN
17+
CREATE SCHEMA "pgmq";
18+
END IF;
19+
END
20+
$$;
21+
22+
-- Ensure pgmq extension exists
23+
do $$
24+
BEGIN
25+
IF NOT EXISTS (
26+
SELECT 1 FROM pg_extension WHERE extname = 'pgmq'
27+
) THEN
28+
CREATE EXTENSION "pgmq" WITH SCHEMA "pgmq" VERSION "1.4.4";
29+
END IF;
30+
END
31+
$$;

0 commit comments

Comments
 (0)