Skip to content

Commit

Permalink
DataSync: Avoid CREATE TABLE large_pg_notifications if not needed
Browse files Browse the repository at this point in the history
  • Loading branch information
mpscholten committed Nov 12, 2024
1 parent e2360aa commit 6fc9158
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions IHP/DataSync/ChangeNotifications.hs
Original file line number Diff line number Diff line change
Expand Up @@ -98,12 +98,19 @@ createNotificationFunction table = [i|
WHEN duplicate_function THEN
null;

CREATE UNLOGGED TABLE IF NOT EXISTS large_pg_notifications (
id UUID DEFAULT uuid_generate_v4() PRIMARY KEY NOT NULL,
payload TEXT DEFAULT null,
created_at TIMESTAMP WITH TIME ZONE DEFAULT now() NOT NULL
);
CREATE INDEX IF NOT EXISTS large_pg_notifications_created_at_index ON large_pg_notifications (created_at);
IF NOT EXISTS (
SELECT FROM pg_catalog.pg_class c
JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace
WHERE c.relname = 'large_pg_notifications'
AND n.nspname = 'public'
) THEN
CREATE UNLOGGED TABLE large_pg_notifications (
id UUID DEFAULT uuid_generate_v4() PRIMARY KEY NOT NULL,
payload TEXT DEFAULT NULL,
created_at TIMESTAMP WITH TIME ZONE DEFAULT now() NOT NULL
);
CREATE INDEX large_pg_notifications_created_at_index ON large_pg_notifications (created_at);
END IF;
END; $$
|]

Expand Down

0 comments on commit 6fc9158

Please sign in to comment.