[]
        
(Showing Draft Content)

Build-In Postgres Database Adapter Schema

Sql

CREATE TABLE IF NOT EXISTS documents (
    id TEXT PRIMARY KEY,
    type TEXT NOT NULL,
    version INT NOT NULL,
    snapshot_version INT NOT NULL
);

CREATE TABLE IF NOT EXISTS operations (
    doc_id TEXT NOT NULL,
    version INTEGER NOT NULL,
    operation TEXT NOT NULL,
    PRIMARY KEY (doc_id, version),
    FOREIGN KEY (doc_id) REFERENCES documents (id) ON DELETE CASCADE
);

CREATE TABLE IF NOT EXISTS snapshot_fragments (
    doc_id TEXT NOT NULL REFERENCES documents(id) ON DELETE CASCADE,
    fragment_id TEXT NOT NULL,
    data TEXT NOT NULL,
    PRIMARY KEY (doc_id, fragment_id)
);

Schema

Table Name

Column Name

Data Type

Description

documents

id

TEXT

Unique identifier for the document

version

INTEGER

Version number of the document

snapshotVersion

INTEGER

Snapshot version number

type

TEXT

Type of the document

operations

doc_id

TEXT

Unique identifier for the document

version

INTEGER

Version of the operation

operation

TEXT

Data related to the operation

fragments

doc_id

TEXT

Unique identifier for the document

fragment_id

TEXT

Unique identifier for the fragment

data

TEXT

Data related to the fragment