You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat: add ops schema reset functionality and update documentation
- Introduced a new script `run-ops-db-schema-reset-k8s.sh` to facilitate a full database schema reset in Kubernetes, addressing checksum mismatches.
- Added a new suspended CronJob `metaboost-db-drop-everything` to drop the public schema on both app and management databases.
- Updated documentation in `DB-MIGRATIONS.md` and `REMOTE-K8S-GITOPS.md` to include detailed instructions for the ops schema reset process.
- Enhanced the `rebootstrap-full-bootstrap.sh` script to create the `uuid-ossp` extension during rebootstrap.
- Updated `kustomization.yaml` to include the new CronJob resource.
Copy file name to clipboardExpand all lines: .cursor/skills/linear-db-migrations/SKILL.md
+2-1Lines changed: 2 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -32,6 +32,7 @@ Treat each chain as **ordered fresh applies**: migration `NNNN` may assume schem
32
32
## Runner and validation
33
33
34
34
- Apply migrations: `bash scripts/database/run-linear-migrations.sh --database app|management` (always pass `--database`; there is no default).
35
+
-**K8s schema reset (checksum mismatch):**`bash scripts/database/run-ops-db-schema-reset-k8s.sh` or `npm run db:ops:schema-reset:k8s` (requires `K8S_NAMESPACE`; runs drop → rebootstrap → migrate → verify → superuser-create jobs).
35
36
-**Credentials:****app** migrations use `DB_APP_MIGRATOR_USER`, `DB_APP_MIGRATOR_PASSWORD`, `DB_APP_NAME`, `DB_HOST`, and `DB_PORT`. **Management** migrations use `DB_MANAGEMENT_MIGRATOR_USER`, `DB_MANAGEMENT_MIGRATOR_PASSWORD`, `DB_MANAGEMENT_NAME`, `DB_HOST`, and `DB_PORT`. Optional: `infra/config/local/db.env` when keys are unset before sourcing.
36
37
- K8s wrapper: `bash scripts/database/run-linear-migrations-k8s.sh` (`--database` required); validates the same keys from Secrets.
37
38
- Validate: `bash scripts/database/validate-linear-migrations.sh` (and `--check-db` to compare on-disk checksums to `linear_migration_history` when a DB is available).
@@ -44,7 +45,7 @@ Treat each chain as **ordered fresh applies**: migration `NNNN` may assume schem
44
45
## Ops bundle (cache busting)
45
46
46
47
-`infra/k8s/base/ops/kustomization.yaml` must list every `.sql` file under the app and management `source` directories so the ops jobs ConfigMaps stay in sync.
47
-
- The ops migration-runtime ConfigMap also bundles `verify-bootstrap-contract.sh` and `rebootstrap-full-bootstrap.sh` for suspended CronJobs `metaboost-db-verify-bootstrap-contract` and `metaboost-db-rebootstrap-roles`.
48
+
- The ops migration-runtime ConfigMap also bundles `verify-bootstrap-contract.sh` and `rebootstrap-full-bootstrap.sh` for suspended CronJobs `metaboost-db-verify-bootstrap-contract`, `metaboost-db-rebootstrap-roles`, and `metaboost-db-drop-everything`.
48
49
- Kustomize may load paths outside the ops directory; when building, use e.g. `kubectl kustomize infra/k8s/base/ops --load-restrictor LoadRestrictionsNone`.
49
50
- Local operator check: `make db_verify_bootstrap_contract` (wraps `scripts/database/verify-bootstrap-contract.sh`).
Copy file name to clipboardExpand all lines: docs/development/DB-MIGRATIONS.md
+39-1Lines changed: 39 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -70,6 +70,7 @@ npm run db:migrate:linear:dry-run:management
70
70
71
71
Suspended CronJobs:
72
72
73
+
-`metaboost-db-drop-everything` — drops `public` schema on app and management DBs (destructive)
73
74
-`metaboost-db-migrate-app`
74
75
-`metaboost-db-migrate-management`
75
76
-`metaboost-db-verify-bootstrap-contract`
@@ -79,7 +80,44 @@ Suspended CronJobs:
79
80
80
81
Trigger one-off jobs during first deploy and any deploy that introduces new migration files. After schema or role recovery, run verify-bootstrap-contract or rebootstrap-roles manually before app rollout.
Copy file name to clipboardExpand all lines: docs/development/k8s/REMOTE-K8S-POSTGRES-REINIT.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -12,7 +12,7 @@ Replace **`metaboost-alpha`** with your namespace if different.
12
12
13
13
**Migrating from the old Deployment layout:** If the namespace still has PVC **`metaboost-postgres-data`** (Deployment-era), replacing it with this StatefulSet creates a **new** PVC **`db-data-metaboost-db-0`**. Back up data first, or delete the old Deployment/PVC when a wipe is acceptable so the new pod initializes cleanly.
14
14
15
-
**Existing data / drift / password rotation without wipe:** Use **§4** (manual SQL from your machine) or delete the Postgres PVC and bring the pod back so **`PGDATA`** is empty and first-start init runs again (**§3**).
15
+
**Existing data / drift / password rotation without wipe:** Use **§4** (manual SQL from your machine), the **ops schema-reset job sequence** in [DB-MIGRATIONS.md](/docs/development/DB-MIGRATIONS.md) (drop → rebootstrap → migrate → verify → superuser), or delete the Postgres PVC and bring the pod back so **`PGDATA`** is empty and first-start init runs again (**§3**).
0 commit comments