OXYGENHUB
# adbc38e7ea09 oxygenhub / crates / hub / migrations / 0079_terraform_states.sql
1.1 KiB · SQL · last changed The hub keeps Terraform and OpenTofu state (closes #252) 18 days ago source blame history raw
1
-- Terraform and OpenTofu state kept by the hub (oxygenhub#252): one row
2
-- per repository and state name, its body sealed with the hub's secrets
3
-- key, its lock, and the last versions for rolling back.
4
CREATE TABLE terraform_states (
5
    repo_id    INTEGER NOT NULL REFERENCES repositories(id) ON DELETE CASCADE,
6
    name       TEXT NOT NULL,
7
    body       BLOB NOT NULL,
8
    serial     INTEGER NOT NULL DEFAULT 0,
9
    lock_id    TEXT NOT NULL DEFAULT '',
10
    lock_info  TEXT NOT NULL DEFAULT '',
11
    locked_by  TEXT NOT NULL DEFAULT '',
12
    locked_ms  INTEGER,
13
    updated_by TEXT NOT NULL DEFAULT '',
14
    updated_ms INTEGER NOT NULL,
15
    PRIMARY KEY (repo_id, name)
16
);
17
CREATE TABLE terraform_state_versions (
18
    id         INTEGER PRIMARY KEY,
19
    repo_id    INTEGER NOT NULL REFERENCES repositories(id) ON DELETE CASCADE,
20
    name       TEXT NOT NULL,
21
    body       BLOB NOT NULL,
22
    serial     INTEGER NOT NULL,
23
    created_by TEXT NOT NULL,
24
    created_ms INTEGER NOT NULL
25
);
26
CREATE INDEX terraform_state_versions_state ON terraform_state_versions(repo_id, name, id);