Skip to content

Commit 50c5f21

Browse files
committed
Updated readme/table structure for deletions
- ShareDB sets `doc_type` and `data` to null in the `snapshots` table when a document is deleted
1 parent 57600c8 commit 50c5f21

File tree

3 files changed

+15
-3
lines changed

3 files changed

+15
-3
lines changed

README.md

+12
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,18 @@ ALTER TABLE snapshots
2828
USING data::jsonb;
2929
```
3030

31+
In addition, the `snapshots` table might have a `NOT NULL` constraint on the `doc_type` and `data` columns that will need to be dropped, since these are set to null when a ShareDB document is deleted via its `.del()` method.
32+
33+
```PLpgSQL
34+
ALTER TABLE snapshots
35+
ALTER COLUMN doc_type
36+
DROP NOT NULL;
37+
38+
ALTER TABLE snapshots
39+
ALTER COLUMN data
40+
DROP NOT NULL;
41+
```
42+
3143
## Usage
3244

3345
`sharedb-postgres` wraps native [node-postgres](https://github.com/brianc/node-postgres), and it supports the same configuration options.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "sharedb-postgres",
3-
"version": "3.0.1-zw",
3+
"version": "3.0.2-zw",
44
"description": "PostgreSQL adapter for ShareDB",
55
"main": "index.js",
66
"scripts": {

structure.sql

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ CREATE TABLE ops (
99
CREATE TABLE snapshots (
1010
collection character varying(255) not null,
1111
doc_id character varying(255) not null,
12-
doc_type character varying(255) not null,
12+
doc_type character varying(255), -- Will be set to null if deleted
1313
version integer not null,
14-
data jsonb not null,
14+
data jsonb, -- Will be set to null if deleted
1515
PRIMARY KEY (collection, doc_id)
1616
);

0 commit comments

Comments
 (0)