diff --git a/notes/bf-1bvca.md b/notes/bf-1bvca.md index f331238..ff50eac 100644 --- a/notes/bf-1bvca.md +++ b/notes/bf-1bvca.md @@ -1,25 +1,57 @@ -# P0: combat_turns Column Migration (bf-1bvca) +# bf-1bvca: Deploy combat_turns Column Migration to apexalgo-iad -## Problem -`acb-index-builder` crashed every 15-min cycle with error: `column m.combat_turns does not exist` +## Summary -## Solution -The schema-init manifest at `declarative-config/k8s/apexalgo-iad/ai-code-battle/acb-schema-init.yml` already contained the combat_turns column definition: +Deployed the `combat_turns` column migration to fix acb-index-builder crashes on apexalgo-iad cluster. -1. **CREATE TABLE** statement (line 46): `combat_turns INTEGER NOT NULL DEFAULT 0` -2. **ALTER TABLE migration** (line 305): `ALTER TABLE matches ADD COLUMN IF NOT EXISTS combat_turns INTEGER NOT NULL DEFAULT 0;` +## Changes Made -The issue was that the schema-init pod had not run since the schema was updated, so the migration had not been applied to the existing database. +### 1. Schema Migration (Already Present) -## Work Completed -1. **Found schema-init manifest**: `declarative-config/k8s/apexalgo-iad/ai-code-battle/acb-schema-init.yml` -2. **Verified schema already includes combat_turns**: Both CREATE TABLE and ALTER TABLE migrations present -3. **Bumped rollout annotation**: Updated `checksum/schema` from `v2-combat-turns-redeploy-2025-06-03` to `v3-combat-turns-redeploy-2026-06-03` -4. **Pushed to declarative-config**: Commit `51e4a36` pushed to main +The `combat_turns` column was already present in `~/declarative-config/k8s/apexalgo-iad/ai-code-battle/acb-schema-init.yml`: -## Verification -- ArgoCD will auto-sync the Deployment annotation change -- Schema-init Pod will restart and apply the migration -- acb-index-builder should succeed on next cycle +- **Line 46** - In CREATE TABLE statement: + ```sql + combat_turns INTEGER NOT NULL DEFAULT 0, + ``` -**Note:** The migration SQL was already present in the schema. The issue was that the schema-init pod had not been restarted since the migration was added, so the production database still lacked the `combat_turns` column. The annotation bump forces the restart. +- **Line 305** - Migration ALTER TABLE statement: + ```sql + ALTER TABLE matches ADD COLUMN IF NOT EXISTS combat_turns INTEGER NOT NULL DEFAULT 0; + ``` + +### 2. Rollout Annotation Bumped + +The deployment annotation was bumped to force a restart of the schema-init pod: + +```yaml +checksum/schema: "v3-combat-turns-redeploy-2026-06-03" +``` + +### 3. Commits Already Pushed + +All changes were committed and pushed to origin/main: + +``` +51e4a36 fix(schema): bump annotation to force schema-init restart for combat_turns column +f74367f feat(apexalgo-iad): bump schema-init rollout annotation for combat_turns migration +00e1f5c feat(apexalgo-iad): add acb-schema-init deployment with combat_turns migration +``` + +## Status + +✅ **Migration SQL is in place** (line 305 of acb-schema-init.yml) +✅ **Changes committed and pushed** to declarative-config +✅ **Rollout annotation bumped** to v3-combat-turns-redeploy-2026-06-03 + +## Next Steps + +ArgoCD should automatically sync the changes to apexalgo-iad. Verify by checking: + +1. ArgoCD app sync status for `ai-code-battle` namespace +2. acb-schema-init pod restarted with new annotation +3. acb-index-builder logs show successful queries without combat_turns errors + +## Note + +The migration was already present in the schema from earlier commits (00e1f5c, f74367f, 51e4a36). The declarative-config repo is clean and up to date with origin/main.