Skip to content

Fix primary key column order in test schema#779

Merged
rickyrombo merged 2 commits intomainfrom
mjp-fix-test-schema-pkeys
Apr 24, 2026
Merged

Fix primary key column order in test schema#779
rickyrombo merged 2 commits intomainfrom
mjp-fix-test-schema-pkeys

Conversation

@rickyrombo
Copy link
Copy Markdown
Contributor

Summary

  • Reorders primary key columns in 10 tables in sql/01_schema.sql to match production: entity ID first, txhash last
  • Mismatched PK order means the btree index can't be used for entity lookups, masking performance issues in tests that wouldn't exist in production

Tables fixed: users, tracks, playlists, follows, saves, reposts, developer_apps, grants, subscriptions, dashboard_wallet_users

Companion ETL migration PR: OpenAudio/go-openaudio#209

Test plan

  • Verified column orders match production pg_dump output
  • Existing tests pass with updated schema

🤖 Generated with Claude Code

Put entity ID columns first and txhash last in all composite primary
keys, matching the production DP schema. Mismatched PK column order
causes the btree index to be useless for entity lookups in tests,
masking performance issues that wouldn't appear in production.

Tables fixed: users, tracks, playlists, follows, saves, reposts,
developer_apps, grants, subscriptions, dashboard_wallet_users

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates the test database schema dump to align primary key column ordering with production so that query plans in tests better reflect production index usage (entity identifier columns first, txhash last).

Changes:

  • Reordered primary key column order for 10 tables in sql/01_schema.sql (e.g., users, tracks, playlists, reposts, saves, etc.).
  • Adjusted dashboard_wallet_users primary key definition to be composite (user_id, wallet).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread sql/01_schema.sql Outdated
Comment thread sql/01_schema.sql
Production was updated to use PRIMARY KEY (wallet) with a separate
index on user_id.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread sql/01_schema.sql
@rickyrombo rickyrombo merged commit d6d3da7 into main Apr 24, 2026
9 checks passed
@rickyrombo rickyrombo deleted the mjp-fix-test-schema-pkeys branch April 24, 2026 01:00
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