diff --git a/instructions.txt b/instructions.txt index 56d59ad..8777c6b 100644 --- a/instructions.txt +++ b/instructions.txt @@ -284,4 +284,67 @@ postgres=# !!!!!!!!!WHEN TESTING NEW NODES OR REFRESHING THE NODES!!!!!!!!! -SET spock.enable_ddl_replication = off; \ No newline at end of file +SET spock.enable_ddl_replication = off; + + +|=============================| +|ADD UUID IN AN EXISTING TABLE| +|=============================| + +CREATE EXTENSION IF NOT EXISTS pgcrypto; +ALTER TABLE public.test_replication +ADD COLUMN uuid_id uuid DEFAULT gen_random_uuid(); +Populate any existing rows that somehow got NULL: +UPDATE public.test_replication +SET uuid_id = gen_random_uuid() +WHERE uuid_id IS NULL; +Make it not null: +ALTER TABLE public.test_replication +ALTER COLUMN uuid_id SET NOT NULL; +Now remove the old primary key: +ALTER TABLE public.test_replication +DROP CONSTRAINT test_replication_pkey; +Make the UUID the new primary key: +ALTER TABLE public.test_replication +ADD PRIMARY KEY (uuid_id); + +|===========================| +|!!!CAUTION AFTER LINKING!!!| +|===========================| +CHECK THIS +SELECT * FROM spock.replication_set_table; + +SELECT + slot_name, + active, + active_pid, + restart_lsn, + confirmed_flush_lsn +FROM pg_replication_slots; + +postgres=# SELECT * +FROM spock.replication_set; + +|===============================| +|CREATE A TABLE NOT USING SPROKE| +|===============================| +SELECT spock.replicate_ddl( +$$ +CREATE TABLE public.vm2_ddl_test ( + uuid_id UUID PRIMARY KEY DEFAULT gen_random_uuid(), + source_node TEXT NOT NULL, + message TEXT, + created_at TIMESTAMPTZ DEFAULT now() +); +$$ +); + +WTF IS THIS!!! +To check if provider is sending data +postgres=# SELECT + slot_name, + active, + active_pid, + restart_lsn, + confirmed_flush_lsn +FROM pg_replication_slots; diff --git a/main.py b/main.py index 6fc3f2d..60c51df 100644 --- a/main.py +++ b/main.py @@ -190,8 +190,13 @@ def link_nodes(data: LinkNodeRequest): SELECT spock.sub_create( subscription_name := %s, provider_dsn := %s, - synchronize_structure := true, - synchronize_data := true + replication_sets := ARRAY[ + 'default', + 'default_insert_only', + 'ddl_sql' + ], + synchronize_structure := false, # CHANGE THIS TO TRUE IF YOU WANT TO SYNCHRONIZE DATA + synchronize_data := false ); """, ( data.subscription_name,