Added publication and subscription support in Schema Diff. Fixes #6153

This commit is contained in:
Pradip Parkale
2021-02-15 16:05:40 +05:30
committed by Akshay Joshi
parent c1e80ac38a
commit 44cc7a308a
32 changed files with 3287 additions and 140 deletions

View File

@@ -1117,3 +1117,44 @@ CREATE USER MAPPING FOR public SERVER test_fs_for_user_mapping;
CREATE USER MAPPING FOR postgres SERVER test_fs_for_user_mapping
OPTIONS (password 'admin123');
-- Publication Script
CREATE TABLE test_schema_diff.table_for_publication (
col1 integer NOT NULL,
col2 text
);
CREATE PUBLICATION for_all_table
FOR ALL TABLES
WITH (publish = 'insert, delete');
CREATE PUBLICATION with_one_table
FOR TABLE test_schema_diff.table_for_publication
WITH (publish = 'insert, delete');
ALTER PUBLICATION with_one_table
RENAME TO with_one_table_alter;
ALTER PUBLICATION with_one_table_alter SET
(publish = 'insert, update');
-- Subscription script
CREATE SUBSCRIPTION "subscription_test1"
CONNECTION 'host=localhost port=5432 user=postgres dbname=edb password=samplepassword'
PUBLICATION sample_publication
WITH (connect = false, enabled = false, create_slot = false, slot_name = None, synchronous_commit = 'off');
ALTER SUBSCRIPTION subscription_test1
CONNECTION 'host=localhost port=5432 user=postgres dbname=postgres';
ALTER SUBSCRIPTION subscription_test1
SET (synchronous_commit = 'remote_apply');
ALTER SUBSCRIPTION subscription_test1
SET PUBLICATION edb WITH (refresh = false);
ALTER SUBSCRIPTION subscription_test1
RENAME TO subscription_test;
DROP SUBSCRIPTION subscription_test;

View File

@@ -1062,3 +1062,50 @@ CREATE USER MAPPING FOR public SERVER test_fs_for_user_mapping
OPTIONS (password 'admin123');
CREATE USER MAPPING FOR postgres SERVER test_fs_for_user_mapping;
-- Publication script
CREATE TABLE test_schema_diff.table_for_publication (
col1 integer NOT NULL,
col2 text
);
CREATE TABLE test_schema_diff.table_for_publication_in_target (
col1 integer NOT NULL,
col2 text
);
CREATE PUBLICATION for_all_table
FOR ALL TABLES
WITH (publish = 'insert, delete');
CREATE PUBLICATION with_one_table_in_target
FOR TABLE test_schema_diff.table_for_publication_in_target
WITH (publish = 'insert, delete');
ALTER PUBLICATION with_one_table_in_target
RENAME TO with_one_table_in_target_alter;
ALTER PUBLICATION with_one_table_in_target_alter SET
(publish = 'insert, update');
-- Subscription script
CREATE SUBSCRIPTION "subscription_test1_in_target"
CONNECTION 'host=localhost port=5432 user=postgres dbname=edb password=samplepassword'
PUBLICATION sample_publication
WITH (connect = false, enabled = false, create_slot = false, slot_name = None, synchronous_commit = 'off');
ALTER SUBSCRIPTION subscription_test1_in_target
CONNECTION 'host=localhost port=5432 user=postgres dbname=postgres';
ALTER SUBSCRIPTION subscription_test1_in_target
SET (synchronous_commit = 'remote_apply');
ALTER SUBSCRIPTION subscription_test1_in_target
SET PUBLICATION edb WITH (refresh = false);
ALTER SUBSCRIPTION subscription_test1_in_target
RENAME TO subscription_test_in_target;
DROP SUBSCRIPTION subscription_test_in_target;

View File

@@ -1116,3 +1116,46 @@ CREATE USER MAPPING FOR public SERVER test_fs_for_user_mapping;
CREATE USER MAPPING FOR postgres SERVER test_fs_for_user_mapping
OPTIONS (password 'admin123');
-- Publication Script
CREATE TABLE test_schema_diff.table_for_publication (
col1 integer NOT NULL,
col2 text
);
CREATE PUBLICATION for_all_table
FOR ALL TABLES
WITH (publish = 'insert, delete');
CREATE PUBLICATION with_one_table
FOR TABLE test_schema_diff.table_for_publication
WITH (publish = 'insert, delete');
ALTER PUBLICATION with_one_table
RENAME TO with_one_table_alter;
ALTER PUBLICATION with_one_table_alter SET
(publish = 'insert, update, truncate');
-- Subscription script
CREATE SUBSCRIPTION "subscription_test1"
CONNECTION 'host=localhost port=5432 user=postgres dbname=edb password=samplepassword'
PUBLICATION sample_publication
WITH (connect = false, enabled = false, create_slot = false, slot_name = None, synchronous_commit = 'off');
ALTER SUBSCRIPTION subscription_test1
CONNECTION 'host=localhost port=5432 user=postgres dbname=postgres';
ALTER SUBSCRIPTION subscription_test1
SET (synchronous_commit = 'remote_apply');
ALTER SUBSCRIPTION subscription_test1
SET PUBLICATION edb WITH (refresh = false);
ALTER SUBSCRIPTION subscription_test1
RENAME TO subscription_test;
DROP SUBSCRIPTION subscription_test;

View File

@@ -1061,3 +1061,51 @@ CREATE USER MAPPING FOR public SERVER test_fs_for_user_mapping
OPTIONS (password 'admin123');
CREATE USER MAPPING FOR postgres SERVER test_fs_for_user_mapping;
-- Publication scripts
CREATE TABLE test_schema_diff.table_for_publication (
col1 integer NOT NULL,
col2 text
);
CREATE TABLE test_schema_diff.table_for_publication_in_target (
col1 integer NOT NULL,
col2 text
);
CREATE PUBLICATION for_all_table
FOR ALL TABLES
WITH (publish = 'insert, delete');
CREATE PUBLICATION with_one_table_in_target
FOR TABLE test_schema_diff.table_for_publication_in_target
WITH (publish = 'insert, delete');
ALTER PUBLICATION with_one_table_in_target
RENAME TO with_one_table_in_target_alter;
ALTER PUBLICATION with_one_table_in_target_alter SET
(publish = 'insert, update, truncate');
-- Subscription script
CREATE SUBSCRIPTION "subscription_test1_in_target"
CONNECTION 'host=localhost port=5432 user=postgres dbname=edb password=samplepassword'
PUBLICATION sample_publication
WITH (connect = false, enabled = false, create_slot = false, slot_name = None, synchronous_commit = 'off');
ALTER SUBSCRIPTION subscription_test1_in_target
CONNECTION 'host=localhost port=5432 user=postgres dbname=postgres';
ALTER SUBSCRIPTION subscription_test1_in_target
SET (synchronous_commit = 'remote_apply');
ALTER SUBSCRIPTION subscription_test1_in_target
SET PUBLICATION edb WITH (refresh = false);
ALTER SUBSCRIPTION subscription_test1_in_target
RENAME TO subscription_test_in_target;
DROP SUBSCRIPTION subscription_test_in_target;

View File

@@ -1117,3 +1117,53 @@ CREATE USER MAPPING FOR public SERVER test_fs_for_user_mapping;
CREATE USER MAPPING FOR postgres SERVER test_fs_for_user_mapping
OPTIONS (password 'admin123');
-- Publication scripts
CREATE TABLE test_schema_diff.table_for_publication (
col1 integer NOT NULL,
col2 text
);
CREATE TABLE test_schema_diff.table_for_publication_in_target (
col1 integer NOT NULL,
col2 text
);
CREATE PUBLICATION for_all_table
FOR ALL TABLES
WITH (publish = 'insert, delete');
CREATE PUBLICATION with_one_table_in_target
FOR TABLE test_schema_diff.table_for_publication_in_target
WITH (publish = 'insert, delete');
ALTER PUBLICATION with_one_table_in_target
OWNER TO managers;
ALTER PUBLICATION with_one_table_in_target
RENAME TO with_one_table_in_target_alter;
ALTER PUBLICATION with_one_table_in_target_alter SET
(publish = 'insert, update, truncate');
-- Subscription script
CREATE SUBSCRIPTION "subscription_test1"
CONNECTION 'host=localhost port=5432 user=postgres dbname=edb password=samplepassword'
PUBLICATION sample_publication
WITH (connect = false, enabled = false, create_slot = false, slot_name = None, synchronous_commit = 'off');
ALTER SUBSCRIPTION subscription_test1
CONNECTION 'host=localhost port=5432 user=postgres dbname=postgres';
ALTER SUBSCRIPTION subscription_test1
SET (synchronous_commit = 'remote_apply');
ALTER SUBSCRIPTION subscription_test1
SET PUBLICATION edb WITH (refresh = false);
ALTER SUBSCRIPTION subscription_test1
RENAME TO subscription_test;
DROP SUBSCRIPTION subscription_test;

View File

@@ -1050,3 +1050,51 @@ CREATE USER MAPPING FOR public SERVER test_fs_for_user_mapping
OPTIONS (password 'admin123');
CREATE USER MAPPING FOR postgres SERVER test_fs_for_user_mapping;
CREATE TABLE test_schema_diff.table_for_publication (
col1 integer NOT NULL,
col2 text
);
CREATE TABLE test_schema_diff.table_for_publication_in_target (
col1 integer NOT NULL,
col2 text
);
CREATE PUBLICATION for_all_table
FOR ALL TABLES
WITH (publish = 'insert, delete');
CREATE PUBLICATION with_one_table_in_target
FOR TABLE test_schema_diff.table_for_publication_in_target
WITH (publish = 'insert, delete');
ALTER PUBLICATION with_one_table_in_target
OWNER TO managers;
ALTER PUBLICATION with_one_table_in_target
RENAME TO with_one_table_in_target_alter;
ALTER PUBLICATION with_one_table_in_target_alter SET
(publish = 'insert, update, truncate');
-- Subscription script
CREATE SUBSCRIPTION "subscription_test1_in_target"
CONNECTION 'host=localhost port=5432 user=postgres dbname=edb password=samplepassword'
PUBLICATION sample_publication
WITH (connect = false, enabled = false, create_slot = false, slot_name = None, synchronous_commit = 'off');
ALTER SUBSCRIPTION subscription_test1_in_target
CONNECTION 'host=localhost port=5432 user=postgres dbname=postgres';
ALTER SUBSCRIPTION subscription_test1_in_target
SET (synchronous_commit = 'remote_apply');
ALTER SUBSCRIPTION subscription_test1_in_target
SET PUBLICATION edb WITH (refresh = false);
ALTER SUBSCRIPTION subscription_test1_in_target
RENAME TO subscription_test_in_target;
DROP SUBSCRIPTION subscription_test_in_target;

View File

@@ -1275,3 +1275,46 @@ CREATE USER MAPPING FOR public SERVER test_fs_for_user_mapping;
CREATE USER MAPPING FOR enterprisedb SERVER test_fs_for_user_mapping
OPTIONS (password 'admin123');
-- Publication Script
CREATE TABLE test_schema_diff.table_for_publication (
col1 integer NOT NULL,
col2 text
);
CREATE PUBLICATION for_all_table
FOR ALL TABLES
WITH (publish = 'insert, delete');
CREATE PUBLICATION with_one_table
FOR TABLE test_schema_diff.table_for_publication
WITH (publish = 'insert, delete');
ALTER PUBLICATION with_one_table
RENAME TO with_one_table_alter;
ALTER PUBLICATION with_one_table_alter SET
(publish = 'insert, update');
-- Subscription script
CREATE SUBSCRIPTION "subscription_test1"
CONNECTION 'host=localhost port=5432 user=postgres dbname=edb password=samplepassword'
PUBLICATION sample_publication
WITH (connect = false, enabled = false, create_slot = false, slot_name = None, synchronous_commit = 'off');
ALTER SUBSCRIPTION subscription_test1
CONNECTION 'host=localhost port=5432 user=postgres dbname=postgres';
ALTER SUBSCRIPTION subscription_test1
SET (synchronous_commit = 'remote_apply');
ALTER SUBSCRIPTION subscription_test1
SET PUBLICATION edb WITH (refresh = false);
ALTER SUBSCRIPTION subscription_test1
RENAME TO subscription_test;
DROP SUBSCRIPTION subscription_test;

View File

@@ -1212,3 +1212,50 @@ CREATE USER MAPPING FOR public SERVER test_fs_for_user_mapping
OPTIONS (password 'admin123');
CREATE USER MAPPING FOR enterprisedb SERVER test_fs_for_user_mapping;
-- Publication script
CREATE TABLE test_schema_diff.table_for_publication (
col1 integer NOT NULL,
col2 text
);
CREATE TABLE test_schema_diff.table_for_publication_in_target (
col1 integer NOT NULL,
col2 text
);
CREATE PUBLICATION for_all_table
FOR ALL TABLES
WITH (publish = 'insert, delete');
CREATE PUBLICATION with_one_table_in_target
FOR TABLE test_schema_diff.table_for_publication_in_target
WITH (publish = 'insert, delete');
ALTER PUBLICATION with_one_table_in_target
RENAME TO with_one_table_in_target_alter;
ALTER PUBLICATION with_one_table_in_target_alter SET
(publish = 'insert, update');
-- Subscription script
CREATE SUBSCRIPTION "subscription_test1_in_target"
CONNECTION 'host=localhost port=5432 user=postgres dbname=edb password=samplepassword'
PUBLICATION sample_publication
WITH (connect = false, enabled = false, create_slot = false, slot_name = None, synchronous_commit = 'off');
ALTER SUBSCRIPTION subscription_test1_in_target
CONNECTION 'host=localhost port=5432 user=postgres dbname=postgres';
ALTER SUBSCRIPTION subscription_test1_in_target
SET (synchronous_commit = 'remote_apply');
ALTER SUBSCRIPTION subscription_test1_in_target
SET PUBLICATION edb WITH (refresh = false);
ALTER SUBSCRIPTION subscription_test1_in_target
RENAME TO subscription_test_in_target;
DROP SUBSCRIPTION subscription_test_in_target;

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff