-
Notifications
You must be signed in to change notification settings - Fork 1
/
Init.txt
72 lines (58 loc) · 3.13 KB
/
Init.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
CREATE SCHEMA outbox_pattern;
CREATE TABLE IF NOT EXISTS outbox_pattern.tbl_outbox
(
message_id uuid NOT NULL,
correlation_id uuid NOT NULL,
pubsub_name text COLLATE pg_catalog."default" NOT NULL,
topic_name text COLLATE pg_catalog."default" NOT NULL,
created_at timestamp with time zone NOT NULL DEFAULT now(),
message_type text COLLATE pg_catalog."default" NOT NULL,
message_content jsonb NOT NULL,
outbox_no smallint NOT NULL,
CONSTRAINT tbl_outbox_pkey PRIMARY KEY (outbox_no, created_at, message_id)
) PARTITION BY RANGE (outbox_no);
ALTER TABLE IF EXISTS outbox_pattern.tbl_outbox
OWNER to postgres;
CREATE TABLE outbox_pattern.tbl_outbox_o0 PARTITION OF outbox_pattern.tbl_outbox
FOR VALUES FROM (0) TO (1) PARTITION BY RANGE (created_at);
ALTER TABLE IF EXISTS outbox_pattern.tbl_outbox_o0
OWNER to postgres;
CREATE TABLE outbox_pattern.tbl_outbox_o1 PARTITION OF outbox_pattern.tbl_outbox
FOR VALUES FROM (1) TO (2) PARTITION BY RANGE (created_at);
ALTER TABLE IF EXISTS outbox_pattern.tbl_outbox_o1
OWNER to postgres;
CREATE TABLE outbox_pattern.tbl_outbox_o2 PARTITION OF outbox_pattern.tbl_outbox
FOR VALUES FROM (2) TO (3) PARTITION BY RANGE (created_at);
ALTER TABLE IF EXISTS outbox_pattern.tbl_outbox_o2
OWNER to postgres;
CREATE TABLE outbox_pattern.tbl_outbox_o3 PARTITION OF outbox_pattern.tbl_outbox
FOR VALUES FROM (3) TO (4) PARTITION BY RANGE (created_at);
ALTER TABLE IF EXISTS outbox_pattern.tbl_outbox_o3
OWNER to postgres;
CREATE TABLE outbox_pattern.tbl_outbox_o4 PARTITION OF outbox_pattern.tbl_outbox
FOR VALUES FROM (4) TO (5) PARTITION BY RANGE (created_at);
ALTER TABLE IF EXISTS outbox_pattern.tbl_outbox_o4
OWNER to postgres;
CREATE PUBLICATION pub_outbox0 FOR TABLE outbox_pattern.tbl_outbox_o0 WITH (publish = 'insert');
CREATE PUBLICATION pub_outbox1 FOR TABLE outbox_pattern.tbl_outbox_o1 WITH (publish = 'insert');
CREATE PUBLICATION pub_outbox2 FOR TABLE outbox_pattern.tbl_outbox_o2 WITH (publish = 'insert');
CREATE PUBLICATION pub_outbox3 FOR TABLE outbox_pattern.tbl_outbox_o3 WITH (publish = 'insert');
CREATE PUBLICATION pub_outbox4 FOR TABLE outbox_pattern.tbl_outbox_o4 WITH (publish = 'insert');
SELECT * FROM pg_create_logical_replication_slot('repslot_outbox0', 'pgoutput');
SELECT * FROM pg_create_logical_replication_slot('repslot_outbox1', 'pgoutput');
SELECT * FROM pg_create_logical_replication_slot('repslot_outbox2', 'pgoutput');
SELECT * FROM pg_create_logical_replication_slot('repslot_outbox3', 'pgoutput');
SELECT * FROM pg_create_logical_replication_slot('repslot_outbox4', 'pgoutput');
-- Table: public.tbl_greeting
-- DROP TABLE IF EXISTS public.tbl_greeting;
CREATE TABLE IF NOT EXISTS public.tbl_greeting
(
id bigint NOT NULL GENERATED ALWAYS AS IDENTITY ( INCREMENT 1 START 1 MINVALUE 1 MAXVALUE 9223372036854775807 CACHE 1 ),
"from" text COLLATE pg_catalog."default" NOT NULL,
"to" text COLLATE pg_catalog."default" NOT NULL,
message text COLLATE pg_catalog."default" NOT NULL,
CONSTRAINT tbl_greeting_pkey PRIMARY KEY (id)
)
TABLESPACE pg_default;
ALTER TABLE IF EXISTS public.tbl_greeting
OWNER to postgres;