interplane.Get Omega
Read in your language

omnet

aien-dev/omnet

Brought by drakestapleton

branch main Branches Tags History

omnet / integration / headscale / downgrade.sql

22 lines · 1204 bytes Raw Blame History
1-- SPDX-License-Identifier: Apache-2.0
2-- Rollback only: return a Headscale v0.29.6 database that the omnet adapter has
3-- used to the exact schema stock Headscale v0.29.6 validates at startup.
4-- Removes what migration 202610251600-omnet-tka-registration added and nothing
5-- else. Run only with Headscale and tkad stopped, on a database whose lock is
6-- already disabled, after a copy of the file (plus -wal/-shm) has been saved.
7-- sqlite3 -bail /var/lib/headscale/db.sqlite < downgrade.sql
8-- Needs sqlite3 3.35 or newer (ALTER TABLE ... DROP COLUMN). ".bail on" below
9-- stops at the first failing statement even without -bail, so an old sqlite3
10-- leaves the transaction uncommitted and the file unchanged.
11-- Rehearsed by integration/e2e/run.sh --scenario runbook (receipt
12-- rollback-to-stock-headscale-on-current-database-reconnects-everyone) with this
13-- exact command, after a run that must fail on a deliberately broken copy.
14.bail on
15PRAGMA foreign_keys = OFF;
16BEGIN;
17ALTER TABLE nodes DROP COLUMN tka_signature;
18ALTER TABLE nodes DROP COLUMN tka_key;
19DROP TABLE omnet_checkpoints;
20DELETE FROM migrations WHERE id = '202610251600-omnet-tka-registration';
21COMMIT;
22PRAGMA foreign_keys = ON;