Skip to content

Commit 2282d5e

Browse files
committed
Source versioning: extend tests
1 parent 8e51024 commit 2282d5e

File tree

6 files changed

+1118
-12
lines changed

6 files changed

+1118
-12
lines changed

integration/mysql/mysql_bootstrap.sql

Lines changed: 118 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ GRANT SELECT, RELOAD, SHOW DATABASES, REPLICATION SLAVE, REPLICATION CLIENT, LOC
99

1010
FLUSH PRIVILEGES;
1111

12+
-- Basic tables
1213
CREATE TABLE IF NOT EXISTS mysql_table1
1314
(
1415
id INT AUTO_INCREMENT PRIMARY KEY,
@@ -31,14 +32,128 @@ CREATE TABLE IF NOT EXISTS mysql_table3
3132
id INT AUTO_INCREMENT PRIMARY KEY
3233
);
3334

35+
-- Table with ENUM type (needs text_columns)
3436
CREATE TABLE IF NOT EXISTS mysql_table4
3537
(
3638
id INT AUTO_INCREMENT PRIMARY KEY,
3739
status ENUM('active', 'inactive', 'deleted') NOT NULL DEFAULT 'active'
3840
);
3941

42+
-- Table with various data types
43+
CREATE TABLE IF NOT EXISTS mysql_table5
44+
(
45+
id INT AUTO_INCREMENT PRIMARY KEY,
46+
name VARCHAR(255),
47+
email VARCHAR(255),
48+
age INT,
49+
salary DECIMAL(10, 2),
50+
is_active BOOLEAN,
51+
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
52+
updated_at TIMESTAMP
53+
);
54+
55+
-- Table with SET type (needs text_columns)
56+
CREATE TABLE IF NOT EXISTS mysql_table6
57+
(
58+
id INT AUTO_INCREMENT PRIMARY KEY,
59+
tags SET('tag1', 'tag2', 'tag3', 'tag4') DEFAULT NULL,
60+
status ENUM('pending', 'approved', 'rejected') DEFAULT 'pending'
61+
);
62+
63+
-- Table with special characters in names
64+
CREATE TABLE IF NOT EXISTS mysql_table7
65+
(
66+
id INT AUTO_INCREMENT PRIMARY KEY,
67+
`name_with_underscores` VARCHAR(255),
68+
`name-with-dashes` VARCHAR(255),
69+
description TEXT,
70+
binary_data BLOB
71+
);
72+
73+
-- Table with nullable columns
74+
CREATE TABLE IF NOT EXISTS mysql_table8
75+
(
76+
id INT AUTO_INCREMENT PRIMARY KEY,
77+
nullable_string VARCHAR(255) NULL,
78+
nullable_int INT NULL,
79+
nullable_timestamp TIMESTAMP NULL,
80+
required_field VARCHAR(255) NOT NULL
81+
);
82+
83+
-- Table with numeric types
84+
CREATE TABLE IF NOT EXISTS mysql_table9
85+
(
86+
id INT AUTO_INCREMENT PRIMARY KEY,
87+
tiny_int TINYINT,
88+
small_int SMALLINT,
89+
medium_int MEDIUMINT,
90+
big_int BIGINT,
91+
float_val FLOAT,
92+
double_val DOUBLE,
93+
decimal_val DECIMAL(10, 2)
94+
);
95+
96+
-- Table with date/time types
97+
CREATE TABLE IF NOT EXISTS mysql_table10
98+
(
99+
id INT AUTO_INCREMENT PRIMARY KEY,
100+
date_col DATE,
101+
time_col TIME,
102+
datetime_col DATETIME,
103+
timestamp_col TIMESTAMP,
104+
year_col YEAR
105+
);
106+
40107
-- Insert sample data
41-
INSERT INTO mysql_table1 (name, about, banned) VALUES ('John Doe', 'Lorem ipsum dolor sit amet', 0), ('Jane Doe', 'Lorem ipsum dolor sit amet', 1), ('Alice', 'Lorem ipsum dolor sit amet', 0), ('Bob', 'Lorem ipsum dolor sit amet', 1), ('Charlie', 'Lorem ipsum dolor sit amet', 0);
42-
INSERT INTO mysql_table2 (id, updated_at) VALUES (1, NOW()), (2, NOW()), (3, NOW()), (4, NOW()), (5, NOW());
43-
INSERT INTO mysql_table2 (id) VALUES (1), (2), (3), (4), (5);
108+
INSERT INTO mysql_table1 (name, about, banned) VALUES
109+
('John Doe', 'Lorem ipsum dolor sit amet', 0),
110+
('Jane Doe', 'Lorem ipsum dolor sit amet', 1),
111+
('Alice', 'Lorem ipsum dolor sit amet', 0),
112+
('Bob', 'Lorem ipsum dolor sit amet', 1),
113+
('Charlie', 'Lorem ipsum dolor sit amet', 0);
114+
115+
INSERT INTO mysql_table2 (id, name, about, banned, updated_at) VALUES
116+
(1, 'Record 1', 'First record', 0, NOW()),
117+
(2, 'Record 2', 'Second record', 1, NOW()),
118+
(3, 'Record 3', 'Third record', 0, NOW()),
119+
(4, 'Record 4', 'Fourth record', 1, NOW()),
120+
(5, 'Record 5', 'Fifth record', 0, NOW());
121+
44122
INSERT INTO mysql_table3 (id) VALUES (NULL), (NULL), (NULL), (NULL), (NULL);
123+
124+
INSERT INTO mysql_table4 (status) VALUES
125+
('active'), ('inactive'), ('deleted'), ('active'), ('inactive');
126+
127+
INSERT INTO mysql_table5 (name, email, age, salary, is_active, created_at) VALUES
128+
('John Doe', '[email protected]', 30, 50000.00, 1, NOW()),
129+
('Jane Smith', '[email protected]', 25, 60000.00, 1, NOW()),
130+
('Bob Johnson', '[email protected]', 35, 55000.00, 0, NOW()),
131+
('Alice Brown', '[email protected]', 28, 65000.00, 1, NOW()),
132+
('Charlie Wilson', '[email protected]', 32, 70000.00, 1, NOW());
133+
134+
INSERT INTO mysql_table6 (tags, status) VALUES
135+
('tag1,tag2', 'pending'),
136+
('tag3', 'approved'),
137+
('tag1,tag3,tag4', 'rejected'),
138+
(NULL, 'pending'),
139+
('tag2', 'approved');
140+
141+
INSERT INTO mysql_table7 (`name_with_underscores`, `name-with-dashes`, description, binary_data) VALUES
142+
('underscore_name', 'dash-name', 'Description with special chars: !@#$%', UNHEX('DEADBEEF')),
143+
('another_underscore', 'another-dash', 'More special chars: &*()', UNHEX('CAFEBABE'));
144+
145+
INSERT INTO mysql_table8 (nullable_string, nullable_int, nullable_timestamp, required_field) VALUES
146+
('Has value', 100, NOW(), 'Required'),
147+
(NULL, NULL, NULL, 'Required'),
148+
('Another value', 200, NOW(), 'Required'),
149+
(NULL, 300, NULL, 'Required');
150+
151+
INSERT INTO mysql_table9 (tiny_int, small_int, medium_int, big_int, float_val, double_val, decimal_val) VALUES
152+
(127, 32767, 8388607, 9223372036854775807, 3.14159, 2.71828, 1234.56),
153+
(-128, -32768, -8388608, -9223372036854775808, -3.14159, -2.71828, -1234.56),
154+
(0, 0, 0, 0, 0.0, 0.0, 0.00);
155+
156+
INSERT INTO mysql_table10 (date_col, time_col, datetime_col, timestamp_col, year_col) VALUES
157+
('2024-01-01', '12:00:00', '2024-01-01 12:00:00', NOW(), 2024),
158+
('2024-06-15', '18:30:00', '2024-06-15 18:30:00', NOW(), 2024),
159+
('2024-12-31', '23:59:59', '2024-12-31 23:59:59', NOW(), 2024);

integration/postgres/postgres_bootstrap.sql

Lines changed: 86 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
ALTER SYSTEM SET wal_level = logical;
22
ALTER ROLE postgres WITH REPLICATION;
33

4+
-- Basic tables
45
CREATE TABLE table1 (
56
id INT GENERATED ALWAYS AS IDENTITY
67
);
@@ -14,14 +15,96 @@ CREATE TABLE table3 (
1415
id INT GENERATED ALWAYS AS IDENTITY
1516
);
1617

17-
-- Enable REPLICA for both tables
18+
-- Table with various data types for testing
19+
CREATE TABLE table4 (
20+
id INT PRIMARY KEY,
21+
name VARCHAR(255),
22+
email VARCHAR(255),
23+
age INT,
24+
salary DECIMAL(10, 2),
25+
is_active BOOLEAN,
26+
created_at TIMESTAMP DEFAULT NOW(),
27+
updated_at TIMESTAMP
28+
);
29+
30+
-- Table with unsupported types that need text_columns
31+
CREATE TABLE table5 (
32+
id INT PRIMARY KEY,
33+
data JSONB,
34+
tags TEXT[],
35+
metadata JSONB
36+
);
37+
38+
-- Table with special characters and edge cases
39+
CREATE TABLE table6 (
40+
id INT PRIMARY KEY,
41+
name_with_dots VARCHAR(255),
42+
"name-with-dashes" VARCHAR(255),
43+
"name with spaces" VARCHAR(255),
44+
description TEXT,
45+
binary_data BYTEA
46+
);
47+
48+
-- Table with nullable columns
49+
CREATE TABLE table7 (
50+
id INT PRIMARY KEY,
51+
nullable_string VARCHAR(255),
52+
nullable_int INT,
53+
nullable_timestamp TIMESTAMP,
54+
required_field VARCHAR(255) NOT NULL
55+
);
56+
57+
-- Table with numeric types
58+
CREATE TABLE table8 (
59+
id SERIAL PRIMARY KEY,
60+
small_int SMALLINT,
61+
big_int BIGINT,
62+
real_num REAL,
63+
double_num DOUBLE PRECISION,
64+
numeric_val NUMERIC(10, 2)
65+
);
66+
67+
-- Enable REPLICA IDENTITY for all tables
1868
ALTER TABLE table1 REPLICA IDENTITY FULL;
1969
ALTER TABLE table2 REPLICA IDENTITY FULL;
2070
ALTER TABLE table3 REPLICA IDENTITY FULL;
71+
ALTER TABLE table4 REPLICA IDENTITY FULL;
72+
ALTER TABLE table5 REPLICA IDENTITY FULL;
73+
ALTER TABLE table6 REPLICA IDENTITY FULL;
74+
ALTER TABLE table7 REPLICA IDENTITY FULL;
75+
ALTER TABLE table8 REPLICA IDENTITY FULL;
2176

22-
-- Create publication on the created tables
23-
CREATE PUBLICATION mz_source FOR TABLE table1, table2, table3;
77+
-- Create publication on all tables
78+
CREATE PUBLICATION mz_source FOR TABLE table1, table2, table3, table4, table5, table6, table7, table8;
2479

80+
-- Insert sample data
2581
INSERT INTO table1 VALUES (1), (2), (3), (4), (5);
2682
INSERT INTO table2 VALUES (1, NOW()), (2, NOW()), (3, NOW()), (4, NOW()), (5, NOW());
2783
INSERT INTO table3 VALUES (1), (2), (3), (4), (5);
84+
85+
INSERT INTO table4 (id, name, email, age, salary, is_active, created_at) VALUES
86+
(1, 'John Doe', '[email protected]', 30, 50000.00, true, NOW()),
87+
(2, 'Jane Smith', '[email protected]', 25, 60000.00, true, NOW()),
88+
(3, 'Bob Johnson', '[email protected]', 35, 55000.00, false, NOW()),
89+
(4, 'Alice Brown', '[email protected]', 28, 65000.00, true, NOW()),
90+
(5, 'Charlie Wilson', '[email protected]', 32, 70000.00, true, NOW());
91+
92+
INSERT INTO table5 (id, data, tags, metadata) VALUES
93+
(1, '{"key": "value", "number": 123}'::jsonb, ARRAY['tag1', 'tag2'], '{"meta": "data"}'::jsonb),
94+
(2, '{"key": "value2", "number": 456}'::jsonb, ARRAY['tag3'], '{"meta": "data2"}'::jsonb),
95+
(3, '{"key": "value3"}'::jsonb, ARRAY['tag1', 'tag3'], NULL::jsonb);
96+
97+
INSERT INTO table6 (id, name_with_dots, "name-with-dashes", "name with spaces", description, binary_data) VALUES
98+
(1, 'table.name', 'table-name', 'table name', 'Description with special chars: !@#$%', E'\\xDEADBEEF'),
99+
(2, 'another.table', 'another-name', 'another name', 'More special chars: &*()', E'\\xCAFEBABE');
100+
101+
INSERT INTO table7 (id, nullable_string, nullable_int, nullable_timestamp, required_field) VALUES
102+
(1, 'Has value', 100, NOW(), 'Required'),
103+
(2, NULL, NULL, NULL, 'Required'),
104+
(3, 'Another value', 200, NOW(), 'Required'),
105+
(4, NULL, 300, NULL, 'Required');
106+
107+
INSERT INTO table8 (small_int, big_int, real_num, double_num, numeric_val) VALUES
108+
(32767, 9223372036854775807, 3.14159, 2.71828, 1234.56),
109+
(-32768, -9223372036854775808, -3.14159, -2.71828, -1234.56),
110+
(0, 0, 0.0, 0.0, 0.00);

0 commit comments

Comments
 (0)