Skip to content

refactor(store): fold migrations 0002..0008 into 0001_init (RIG-4556) - #1766

Merged
mattwilkinsonn merged 2 commits into
mainfrom
compass-agent/rig-4556-collapse-migrations
Oct 6, 2026
Merged

mattwilkinsonn merged 2 commits into
mainfrom
compass-agent/rig-4556-collapse-migrations

Conversation

@rigel-mintaka

@rigel-mintaka rigel-mintaka commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Folds migrations 0002..0008 into 0001_init.sql for the dogfood reset (RIG-4556). The mattfw dev database is wiped, so migration history is dead weight again.

Change

  • 0001_init.sql now creates everything the folded files added:
    • tokens.tenant_id
    • session_bindings.usage_interval_id
    • issues.search_tsv and compass_labels_text
    • linear_agent_sessions.linear_issue_identifier
    • the token-usage tables and the compute-usage log
    • account_tour_state
  • Their grants, revokes, RLS policies and updated_at triggers move into the existing 0001 blocks.
  • Deleted the 0002..0008 files and the pgtests that replayed them over a v1 database: backfill_empty_tenant, token_tenant_migration, migrate_upgrade.
  • applyV1Only and execAsSystem move to the remaining tests that use them.
  • server_secrets_pgtest now also pins the compute log's withheld UPDATE and DELETE.

pg_dump schema diff

The test applies main's 0001..0008 chain to one database and the folded 0001 to another, then runs pg_dump --schema-only --no-owner on each.

chain files: 0001_init.sql 0002_backfill_empty_tenant.sql 0003_token_usage.sql 0004_token_tenant.sql 0005_issues_search.sql 0006_compute_usage.sql 0007_account_tour_state.sql 0008_linear_issue_identifier.sql
folded files: 0001_init.sql
--- schema diff (0 bytes) ---
sha256 chain.sql  = folded.sql = 725d7922e85274791274df50ee38198d2746e61c847ebca6f3609428042ee2e9

The data dump differs only in the now() timestamps of the seeded token_usage_prune_horizon row.

The check can fail. Moving tokens.tenant_id before revoked_at produces a non-empty diff.

Gate

migration-immutability rejects this PR by design, so rollup stays red. Matt ruled option C on RIG-4572: this PR needs Matt's admin-bypass merge of the red rollup. Every other check must be green.

After merge

The dev database is wiped for dogfood, so migration history is dead
weight again. Fold every migration into 0001_init.sql, delete the folded
files and the tests that replayed them over a v1 database. A fresh
Open produces a byte-identical pg_dump schema.

Co-authored-by: Matt Wilkinson <matt@rigel.build>
@trunk-io

trunk-io Bot commented Oct 6, 2026 •

Copy link
Copy Markdown

😎 This pull request was merged.

@linear-code

linear-code Bot commented Oct 6, 2026

Copy link
Copy Markdown

RIG-4556

@github-actions

github-actions Bot commented Oct 6, 2026 •

Copy link
Copy Markdown

Compass engineering docs preview: https://compass-agent-rig-4556-colla.compass-eng-docs.pages.dev

Deployed from compass-agent/rig-4556-collapse-migrations at f0c4898.

Changed pages:

…1 (RIG-4556)

Co-authored-by: Matt Wilkinson <matt@rigel.build>
@mattwilkinsonn
mattwilkinsonn marked this pull request as ready for review October 6, 2026 04:47
@mattwilkinsonn
mattwilkinsonn self-requested a review as a code owner October 6, 2026 04:47
@mattwilkinsonn
mattwilkinsonn merged commit 872dd71 into main Oct 6, 2026
14 of 16 checks passed
@mattwilkinsonn
mattwilkinsonn deleted the compass-agent/rig-4556-collapse-migrations branch October 6, 2026 04:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants