Uh oh!
There was an error while loading. Please reload this page.
forked from zbryikt/sharedb-postgres-jsonb
- Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathstructure.sql
More file actions
Latest commit
28 lines (24 loc) · 784 Bytes
/
Copy pathstructure.sql
File metadata and controls
28 lines (24 loc) · 784 Bytes
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
CREATETABLEIF NOT EXISTS ops (
collection character varying(255) not null,
doc_id character varying(255) not null,
version integernot null,
operation jsonb not null, -- {v:0, create:{...}} or {v:n, op:[...]}
PRIMARY KEY (collection, doc_id, version)
);
CREATETABLEIF NOT EXISTS snapshots (
collection character varying(255) not null,
doc_id character varying(255) not null,
doc_type character varying(255) not null,
version integernot null,
data jsonb not null,
PRIMARY KEY (collection, doc_id)
);
CREATEINDEXIF NOT EXISTS snapshots_version ON snapshots (collection, doc_id);
ALTERTABLE ops
ALTER COLUMN operation
SET DATA TYPE jsonb
USING operation::jsonb;
ALTERTABLE snapshots
ALTER COLUMN data
SET DATA TYPE jsonb
USING data::jsonb;