summaryrefslogtreecommitdiffstats
path: root/cmd/icingadb-migrate/embed/previous_hard_state_cache_schema.sql
blob: 315f22dc9ab4abba2c2cc5fc21fbb608b8c54ff3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
PRAGMA main.auto_vacuum = 1;

-- Icinga DB's state_history#previous_hard_state per IDO's icinga_statehistory#statehistory_id.
CREATE TABLE IF NOT EXISTS previous_hard_state (
    history_id          INT PRIMARY KEY,
    previous_hard_state INT NOT NULL
);

-- Helper table, the current last_hard_state per icinga_statehistory#object_id.
CREATE TABLE IF NOT EXISTS next_hard_state (
    object_id       INT PRIMARY KEY,
    next_hard_state INT NOT NULL
);

-- Helper table for stashing icinga_statehistory#statehistory_id until last_hard_state changes.
CREATE TABLE IF NOT EXISTS next_ids (
    object_id  INT NOT NULL,
    history_id INT NOT NULL
);

CREATE INDEX IF NOT EXISTS next_ids_object_id ON next_ids (object_id);
CREATE INDEX IF NOT EXISTS next_ids_history_id ON next_ids (history_id);