Skip to main content

SCHEMA_SQL

Constant SCHEMA_SQL 

Source
pub const SCHEMA_SQL: &str = "CREATE TABLE IF NOT EXISTS heer_nodes (\n    node_id       INTEGER PRIMARY KEY,\n    name          TEXT NOT NULL,\n    description   TEXT,\n    is_active     BOOLEAN DEFAULT true,\n    created_at    TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,\n    last_accessed TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP\n);\n\nCREATE TABLE IF NOT EXISTS heer_config (\n    id                  INTEGER PRIMARY KEY CHECK (id = 1),\n    epoch               TIMESTAMP NOT NULL,\n    precision           VARCHAR(2) NOT NULL DEFAULT \'ns\',\n    ranj_epoch_offset   NUMERIC(30,0) NOT NULL DEFAULT 0,\n    updated_at          TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP\n);\n\nCOMMENT ON COLUMN heer_config.ranj_epoch_offset IS\n\'Extra time units added to the RanjId timestamp to represent epochs beyond \'\n\'the range of TIMESTAMP (e.g. the Big Bang). The unit matches the RanjId \'\n\'precision \u{2014} microseconds by default. When 0, the epoch TIMESTAMP is used \'\n\'directly. When set, current_tick = (now - epoch) + ranj_epoch_offset.\';\n\nCREATE TABLE IF NOT EXISTS heer_node_state (\n    node_id         INTEGER PRIMARY KEY\n                    REFERENCES heer_nodes(node_id) ON DELETE CASCADE,\n    last_id_time    BIGINT NOT NULL DEFAULT 0,\n    last_sequence   SMALLINT NOT NULL DEFAULT 0,\n    updated_at      TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP\n);\n\nCOMMENT ON TABLE heer_node_state IS\n\'Internal state for HeerId generator (one row per node). Do not modify manually.\';\n\nCREATE TABLE IF NOT EXISTS heer_ranj_node_state (\n    node_id         INTEGER PRIMARY KEY\n                    REFERENCES heer_nodes(node_id) ON DELETE CASCADE,\n    last_id_time    NUMERIC(30,0) NOT NULL DEFAULT 0,\n    last_sequence   INTEGER NOT NULL DEFAULT 0,\n    updated_at      TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP\n);\n";