-
Notifications
You must be signed in to change notification settings - Fork 0
/
create_postgres_tables.sql
70 lines (56 loc) · 2.08 KB
/
create_postgres_tables.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
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
CREATE SCHEMA IF NOT EXISTS attribute_registry AUTHORIZATION <<POSTGRES_USER>>;
CREATE TABLE IF NOT EXISTS attribute_registry.event_journal(
ordering BIGSERIAL,
persistence_id VARCHAR(255) NOT NULL,
sequence_number BIGINT NOT NULL,
deleted BOOLEAN DEFAULT FALSE NOT NULL,
writer VARCHAR(255) NOT NULL,
write_timestamp BIGINT,
adapter_manifest VARCHAR(255),
event_ser_id INTEGER NOT NULL,
event_ser_manifest VARCHAR(255) NOT NULL,
event_payload BYTEA NOT NULL,
meta_ser_id INTEGER,
meta_ser_manifest VARCHAR(255),
meta_payload BYTEA,
PRIMARY KEY(persistence_id, sequence_number)
);
CREATE UNIQUE INDEX event_journal_ordering_idx ON attribute_registry.event_journal(ordering);
CREATE TABLE IF NOT EXISTS attribute_registry.event_tag(
event_id BIGINT,
tag VARCHAR(256),
PRIMARY KEY(event_id, tag),
CONSTRAINT fk_event_journal
FOREIGN KEY(event_id)
REFERENCES attribute_registry.event_journal(ordering)
ON DELETE CASCADE
);
CREATE TABLE IF NOT EXISTS attribute_registry.snapshot (
persistence_id VARCHAR(255) NOT NULL,
sequence_number BIGINT NOT NULL,
created BIGINT NOT NULL,
snapshot_ser_id INTEGER NOT NULL,
snapshot_ser_manifest VARCHAR(255) NOT NULL,
snapshot_payload BYTEA NOT NULL,
meta_ser_id INTEGER,
meta_ser_manifest VARCHAR(255),
meta_payload BYTEA,
PRIMARY KEY(persistence_id, sequence_number)
);
CREATE TABLE IF NOT EXISTS attribute_registry.akka_projection_offset_store (
projection_name VARCHAR(255) NOT NULL,
projection_key VARCHAR(255) NOT NULL,
current_offset VARCHAR(255) NOT NULL,
manifest VARCHAR(4) NOT NULL,
mergeable BOOLEAN NOT NULL,
last_updated BIGINT NOT NULL,
PRIMARY KEY(projection_name, projection_key)
);
CREATE INDEX IF NOT EXISTS projection_name_index ON attribute_registry.akka_projection_offset_store (projection_name);
CREATE TABLE IF NOT EXISTS attribute_registry.akka_projection_management (
projection_name VARCHAR(255) NOT NULL,
projection_key VARCHAR(255) NOT NULL,
paused BOOLEAN NOT NULL,
last_updated BIGINT NOT NULL,
PRIMARY KEY(projection_name, projection_key)
);