forked from microservices-patterns/ftgo-application
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtemplate
105 lines (89 loc) · 2.79 KB
/
template
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
DROP table IF EXISTS events;
DROP table IF EXISTS entities;
DROP table IF EXISTS snapshots;
DROP table IF EXISTS cdc_monitoring;
create table events (
event_id varchar(1000) PRIMARY KEY,
event_type varchar(1000),
event_data varchar(1000) NOT NULL,
entity_type VARCHAR(1000) NOT NULL,
entity_id VARCHAR(1000) NOT NULL,
triggering_event VARCHAR(1000),
metadata VARCHAR(1000),
published TINYINT DEFAULT 0
);
CREATE INDEX events_idx ON events(entity_type, entity_id, event_id);
CREATE INDEX events_published_idx ON events(published, event_id);
create table entities (
entity_type VARCHAR(1000),
entity_id VARCHAR(1000),
entity_version VARCHAR(1000) NOT NULL,
PRIMARY KEY(entity_type, entity_id)
);
CREATE INDEX entities_idx ON events(entity_type, entity_id);
create table snapshots (
entity_type VARCHAR(1000),
entity_id VARCHAR(1000),
entity_version VARCHAR(1000),
snapshot_type VARCHAR(1000) NOT NULL,
snapshot_json VARCHAR(1000) NOT NULL,
triggering_events VARCHAR(1000),
PRIMARY KEY(entity_type, entity_id, entity_version)
);
DROP Table IF Exists message;
DROP Table IF Exists received_messages;
DROP Table IF Exists offset_store;
CREATE TABLE message (
id VARCHAR(767) PRIMARY KEY,
destination VARCHAR(1000) NOT NULL,
headers VARCHAR(1000) NOT NULL,
payload VARCHAR(1000) NOT NULL,
published SMALLINT DEFAULT 0,
creation_time BIGINT
);
CREATE INDEX message_published_idx ON message(published, id);
CREATE TABLE received_messages (
consumer_id VARCHAR(767),
message_id VARCHAR(767),
PRIMARY KEY(consumer_id, message_id),
creation_time BIGINT
);
CREATE TABLE offset_store(
client_name VARCHAR(255) NOT NULL PRIMARY KEY,
serialized_offset VARCHAR(255)
);
DROP Table IF Exists saga_instance_participants;
DROP Table IF Exists saga_instance;
DROP Table IF Exists saga_lock_table;
DROP Table IF Exists saga_stash_table;
CREATE TABLE saga_instance_participants (
saga_type VARCHAR(100) NOT NULL,
saga_id VARCHAR(100) NOT NULL,
destination VARCHAR(100) NOT NULL,
resource VARCHAR(100) NOT NULL,
PRIMARY KEY(saga_type, saga_id, destination, resource)
);
CREATE TABLE saga_instance(
saga_type VARCHAR(100) NOT NULL,
saga_id VARCHAR(100) NOT NULL,
state_name VARCHAR(100) NOT NULL,
last_request_id VARCHAR(100),
end_state INT(1),
compensating INT(1),
saga_data_type VARCHAR(1000) NOT NULL,
saga_data_json VARCHAR(1000) NOT NULL,
PRIMARY KEY(saga_type, saga_id)
);
create table saga_lock_table(
target VARCHAR(100) PRIMARY KEY,
saga_type VARCHAR(100) NOT NULL,
saga_Id VARCHAR(100) NOT NULL
);
create table saga_stash_table(
message_id VARCHAR(100) PRIMARY KEY,
target VARCHAR(100) NOT NULL,
saga_type VARCHAR(100) NOT NULL,
saga_id VARCHAR(100) NOT NULL,
message_headers VARCHAR(1000) NOT NULL,
message_payload VARCHAR(1000) NOT NULL
);