omnet
aien-dev/omnet
Brought by drakestapleton
omnet / integration / headscale / downgrade.sql
| 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 |
| 15 | PRAGMA foreign_keys = OFF; |
| 16 | BEGIN; |
| 17 | ALTER TABLE nodes DROP COLUMN tka_signature; |
| 18 | ALTER TABLE nodes DROP COLUMN tka_key; |
| 19 | DROP TABLE omnet_checkpoints; |
| 20 | DELETE FROM migrations WHERE id = '202610251600-omnet-tka-registration'; |
| 21 | COMMIT; |
| 22 | PRAGMA foreign_keys = ON; |