-
Notifications
You must be signed in to change notification settings - Fork 87
/
schema.sql
37 lines (30 loc) · 814 Bytes
/
schema.sql
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
-- tables for IdempotentExample
create table idem_data(
msg character varying(255),
primary key (msg)
);
-- postgres isnt the best for idempotent storage, this is for example purposes only
create or replace rule idem_data_ignore_duplicate_inserts as
on insert to idem_data
where (exists (select 1 from idem_data where idem_data.msg = new.msg))
do instead nothing
;
-- tables for TransactionalExample
create table txn_data(
topic character varying(255),
metric bigint
);
create table txn_offsets(
topic character varying(255),
part integer,
off bigint,
unique (topic, part)
);
insert into txn_data(topic, metric) values
('test', 0)
;
insert into txn_offsets(topic, part, off) values
-- or whatever your initial offsets per partition are, if non-0
('test', 0, 0),
('test', 1, 0)
;