Public: anyone can read this; the crew can change it.
Repo transfer with redirects: move a repository to another owner (e.g. an org) without breaking URLs, git remotes or the crew #549
Moving a repository to another owner without breaking its old addresses (#488), and a fix for the deploy failure that closed #501. Transfer (unchanged from #501): POST /api/v1/repos/:owner/:name/transfer {"newOwner"}, or Settings → Danger zone, moves a repository to yourself or to an org you administer.
stopped closed without shipping deploy 8c6f036
2 earlier comments
Moving a repository to another owner without breaking its old addresses (#488), merged with current main. This merge changes the redirect table from migration 43 to 44, so look at migration 44 first.
Transfer: POST /api/v1/repos/:owner/:name/transfer {"newOwner"}, or Settings → Danger zone, moves a repository to yourself or to an org you administer.
- The bare repo moves, and every fork's alternates are repointed to the new path.
- The old owner/name goes into a new
repo_redirecttable. - Old pages and API paths answer 301 (308 for writes), and git over HTTPS follows the redirect.
- SSH serves the repository and prints a line naming the new path, but only to someone who may read it.
- Everything else (pulls, app and previews, crew, secrets, runs) is keyed by repo id, so it moves with the row.
- A repository created later at the old path takes the address back.
Migration 44: previews keep their database between pushes. This branch's redirect table has been numbered 42, then 43, then 44, as main released its own migrations at those numbers:
- #501's preview ran the table as 42 and never ran main's 42 (the usage ledger rebuild with a
kindcolumn), so it failed to boot withtable repo_redirect already exists. - This pull's preview ran it as 43 and never ran main's 43 (which rewords interrupted runs' park notes).
So a migration may now be code as well as SQL (Migration in src/kernel/db.ts), and 44 is code:
- If the ledger has no
kindcolumn, it runs main's 42 exactly as written. - If
repo_redirectalready exists, it runs main's 43 exactly as written. Its UPDATE matches nothing it has already reworded. - It creates the table and its index only if they are missing.
On a database that ran main's migrations in order, 44 only adds the table. Plain SQL can't check whether a column or table exists, which is why this step is code. Migration 37 handled a similar renumbering in SQL alone.
Tests: three migration tests at the end of test/transfer.test.ts rebuild each kind of database and boot it with today's list:
- #501's preview (1–41, then the table as 42): gets
kindand theplatformsubscription. - This pull's preview (1–42, then the table as 43): an interrupted park note on it is reworded.
main's order (1–43): 42 does not run twice, and a park note written after 43 is left as it is.
The union type needed a cast in two existing tests, test/usage.test.ts and test/crew-parks.test.ts. Neither test's behaviour changed.
forge.json keeps main's new crew-parks in the check and adds transfer. The full check passes: 698 tests, 0 failed.
Not done: the issue's ask that running and queued runs be requeued against the new path. Runs are keyed by repo id and look up their git paths when they use them, so they follow the move without that step.
🤖 Generated with Claude Code
Moving a repository to another owner without breaking its old addresses (#488), merged with current main. The only conflict in this merge was the check list in forge.json; it now runs both main's new told-by and this pull's transfer. main added no migration this time, so the redirect table stays at 44.
Transfer: POST /api/v1/repos/:owner/:name/transfer {"newOwner"}, or Settings → Danger zone, moves a repository to yourself or to an org you administer.
- The bare repo moves, and every fork's alternates are repointed to the new path.
- The old owner/name goes into a new
repo_redirecttable. - Old pages and API paths answer 301 (308 for writes), and git over HTTPS follows the redirect.
- SSH serves the repository and prints a line naming the new path, but only to someone who may read it.
- Everything else (pulls, app and previews, crew, secrets, runs) is keyed by repo id, so it moves with the row.
- A repository created later at the old path takes the address back.
Migration 44: previews keep their database between pushes. This branch's redirect table has been numbered 42, then 43, then 44, as main released its own migrations at those numbers:
- #501's preview ran the table as 42 and never ran main's 42 (the usage ledger rebuild with a
kindcolumn), so it failed to boot withtable repo_redirect already exists. - This pull's preview ran it as 43 and never ran main's 43 (which rewords interrupted runs' park notes).
So a migration may now be code as well as SQL (Migration in src/kernel/db.ts), and 44 is code:
- If the ledger has no
kindcolumn, it runs main's 42 exactly as written. - If
repo_redirectalready exists, it runs main's 43 exactly as written. Its UPDATE matches nothing it has already reworded. - It creates the table and its index only if they are missing.
On a database that ran main's migrations in order, 44 only adds the table. Plain SQL can't check whether a column or table exists, which is why this step is code.
Tests: three migration tests at the end of test/transfer.test.ts rebuild each kind of database and boot it with today's list:
- #501's preview (1–41, then the table as 42): gets
kindand theplatformsubscription. - This pull's preview (1–42, then the table as 43): an interrupted park note on it is reworded.
main's order (1–43): 42 does not run twice, and a park note written after 43 is left as it is.
The union type needed a cast in two existing tests, test/usage.test.ts and test/crew-parks.test.ts. Neither test's behaviour changed.
The full forge.json check passes: 703 tests, 0 failed.
Not done: the issue's ask that running and queued runs be requeued against the new path. Runs are keyed by repo id and look up their git paths when they use them, so they follow the move without that step.
🤖 Generated with Claude Code
Moving a repository to another owner without breaking its old addresses (#488), and a fix for the deploy failure that closed #501.
Transfer (unchanged from #501):
POST /api/v1/repos/:owner/:name/transfer {"newOwner"}, or Settings → Danger zone, moves a repository to yourself or to an org you administer.repo_redirecttable.Why #501's preview never booted: it failed with
SQLiteError: table repo_redirect already exists. The preview keeps its database between pushes. Before the merge with main, it had runrepo_redirectas migration 42. The merge renumbered that to 43, so on that database main's own 42 (every credential becomes a subscription; the usage ledger is rebuilt with akindcolumn) was counted as applied but never ran. Then 43 tried to create the table a second time.The fix:
Migrationinsrc/kernel/db.ts). Use it only where SQL can't express the condition.usagehas nokindcolumn, it runs main's migration 42 exactly as written, then createsrepo_redirectand its index only if they are missing.kindcan't be recomputed fromrun, so a SQL-only replay would lose data.What to look at: migration 43 in
src/core/schema.ts, and the two new tests at the end oftest/transfer.test.ts:test/usage.test.tschanged only to castmigrations[36]to a string now that the array type is a union; its behaviour is the same.Test results: the full
forge.jsoncheck ran with 3 timeouts inappsandapps-adversarial(30 s and 60 s). That run overlapped a briefgit stashof the fix and a boot test of the app on the same machine. Rerun alone, those two files pass 119/119. The rest of the check passed. A fresh boot answers 200 on/healthzand/.Not done: the issue's ask that running and queued runs be requeued against the new path. Runs are keyed by repo id and the git paths are resolved when a run uses them, so they follow the move without that step.
🤖 Generated with Claude Code
Closes #488