-
Notifications
You must be signed in to change notification settings - Fork 152
/
pglogical--1.0.0--1.0.1.sql
21 lines (18 loc) · 893 Bytes
/
pglogical--1.0.0--1.0.1.sql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
CREATE OR REPLACE FUNCTION pglogical.create_subscription(subscription_name name, provider_dsn text,
replication_sets text[] = '{default,default_insert_only,ddl_sql}', synchronize_structure boolean = true,
synchronize_data boolean = true, forward_origins text[] = '{all}')
RETURNS oid STRICT VOLATILE LANGUAGE c AS 'MODULE_PATHNAME', 'pglogical_create_subscription';
DO $$
BEGIN
IF (SELECT count(1) FROM pglogical.node) > 0 THEN
SELECT * FROM pglogical.create_replication_set('ddl_sql', true, false, false, false);
END IF;
END; $$;
UPDATE pglogical.subscription SET sub_replication_sets = array_append(sub_replication_sets, 'ddl_sql');
WITH applys AS (
SELECT sub_name FROM pglogical.subscription WHERE sub_enabled
),
disable AS (
SELECT pglogical.alter_subscription_disable(sub_name, true) FROM applys
)
SELECT pglogical.alter_subscription_enable(sub_name, true) FROM applys;