Commit aa36656
feat(batch): backfill-installation-membership CLI for PR 7 deploy prep (#283 PR 6/7)
One-shot data migration that runs after PR 1's schema deploy and before PR 7
flips repository lookups to strict mode. Assigns github_installation_id and
seeds repository_installation_memberships for organizations whose GitHub App
mode has exactly one active installation.
batch/commands/backfill-installation-membership.ts:
- Decision rules per org:
- integrations.method = 'token' → skip (PAT mode never uses installation ids)
- 0 active GitHub App links → skip + warn (org needs reinstall before PR 7)
- exactly 1 active link → assign every NULL repo to that installation
- 2+ active links → skip and list (operator must use reassign-broken-repositories)
- --dry-run flag for safe inspection
- Best-effort GitHub API call to seed memberships from installation_repositories;
failures fall back to crawl-time membership repair
- Cross-store rule (tenant first / shared second) maintained
- Idempotent: WHERE github_installation_id IS NULL filter
batch/cli.ts:
- registered backfill-installation-membership command
tests (backfill-installation-membership.test.ts):
- single active link → backfills repos and memberships
- token method → skipped, no writes
- multi active link → not backfilled
- dry-run does not write
- idempotent: re-running on already-backfilled rows is a no-op
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>1 parent d0f0617 commit aa36656
3 files changed
Lines changed: 635 additions & 0 deletions
File tree
- batch
- commands
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
145 | 145 | | |
146 | 146 | | |
147 | 147 | | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
148 | 175 | | |
149 | 176 | | |
150 | 177 | | |
| |||
184 | 211 | | |
185 | 212 | | |
186 | 213 | | |
| 214 | + | |
187 | 215 | | |
188 | 216 | | |
189 | 217 | | |
0 commit comments