Initial table definitions and coding for repmgr client utility

This commit is contained in:
Ian Barwick
2017-04-19 22:41:20 +09:00
parent 2704ab0536
commit 1631917715
7 changed files with 227 additions and 8 deletions

View File

@@ -3,5 +3,33 @@
CREATE TABLE nodes (
node_id INTEGER PRIMARY KEY,
type TEXT NOT NULL CHECK (type IN('master','standby','witness','bdr'))
upstream_node_id INTEGER NULL REFERENCES nodes (node_id) DEFERRABLE,
active BOOLEAN NOT NULL DEFAULT TRUE,
node_name TEXT NOT NULL,
type TEXT NOT NULL CHECK (type IN('master','standby','witness','bdr')),
priority INT NOT NULL DEFAULT 100,
conninfo TEXT NOT NULL,
slot_name TEXT NULL
);
CREATE TABLE events (
node_id INTEGER NOT NULL,
event TEXT NOT NULL,
successful BOOLEAN NOT NULL DEFAULT TRUE,
event_timestamp TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT CURRENT_TIMESTAMP,
details TEXT NULL
);
CREATE VIEW show_nodes AS
SELECT n.node_id,
n.node_name,
un.node_name AS upstream_node_name,
n.type,
n.priority,
n.conninfo
FROM nodes n
LEFT JOIN nodes un
ON un.node_id = n.upstream_node_id;