Skip to content

Conversation

@battermann
Copy link
Contributor

@battermann battermann commented Jan 15, 2026

https://wearezeta.atlassian.net/browse/WPB-22811

backendA=# EXPLAIN select value, conversation, password, GREATEST(0, FLOOR(EXTRACT(EPOCH FROM (expires_at - now ())))) AS ttl_sec from conversation_codes where key = '8UZlQIPzoV6Rw_fADs4p' AND scope = 1 AND expires_at > now ();
                                             QUERY PLAN
----------------------------------------------------------------------------------------------------
 Index Scan using conversation_codes_pkey on conversation_codes  (cost=0.15..8.19 rows=1 width=112)
   Index Cond: ((key = '8UZlQIPzoV6Rw_fADs4p'::text) AND (scope = 1))
   Filter: (expires_at > now())
(3 rows)

Checklist

  • Add a new entry in an appropriate subdirectory of changelog.d
  • Read and follow the PR guidelines

@zebot zebot added the ok-to-test Approved for running tests in CI, overrides not-ok-to-test if both labels exist label Jan 15, 2026
Base automatically changed from WPB-22811-migrate-conversation-codes-table-to-postgres to develop January 16, 2026 08:39
@battermann battermann force-pushed the WPB-22811-migrate-conversation-codes-table-to-postgres-main branch 4 times, most recently from 9aac6c1 to 337dd3c Compare January 20, 2026 09:41
@battermann battermann marked this pull request as ready for review January 20, 2026 09:50
@battermann battermann requested review from a team as code owners January 20, 2026 09:50
@battermann battermann requested a review from Copilot January 20, 2026 11:24
Copy link
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

This PR migrates the conversation codes table from Cassandra to PostgreSQL, following the same pattern used for the conversation table migration. The implementation includes a PostgreSQL store, dual-write capability during migration, and a background worker to migrate existing data.

Changes:

  • Added PostgreSQL implementation for conversation codes storage with appropriate schema and indexes
  • Implemented dual-write pattern to write to both Cassandra and PostgreSQL during migration
  • Created background worker migration task to migrate existing conversation codes from Cassandra to PostgreSQL
  • Updated configuration to allow choosing storage backend (Cassandra, PostgreSQL, or migration mode)

Reviewed changes

Copilot reviewed 36 out of 36 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
postgres-schema.sql Added conversation_codes table schema and indexes
libs/wire-subsystems/postgres-migrations/20260115150600-conversation-codes.sql PostgreSQL migration script creating conversation_codes table
libs/wire-subsystems/src/Wire/CodeStore/Postgres.hs PostgreSQL implementation of CodeStore operations
libs/wire-subsystems/src/Wire/CodeStore/DualWrite.hs Dual-write interpreter for migration phase
libs/wire-subsystems/src/Wire/CodeStore/Migration.hs Migration logic to copy codes from Cassandra to PostgreSQL
libs/wire-subsystems/src/Wire/Migration.hs Shared migration utilities extracted from conversation migration
libs/wire-subsystems/src/Wire/CodeStore/Scope.hs Added PostgreSQL marshalling instances for Scope
libs/wire-api/src/Wire/API/PostgresMarshall.hs Added marshalling instances for Code.Key, Code.Value, and Password
services/galley/src/Galley/App.hs Added interpreter selection based on configuration
services/background-worker/src/Wire/PostgresMigrations.hs Added conversation codes migration worker
services/background-worker/src/Wire/BackgroundWorker.hs Integrated conversation codes migration into worker lifecycle
integration/test/Test/Migration/ConversationCodes.hs Integration tests for conversation codes migration
charts/*/values.yaml Added conversationCodes configuration option
docs/src/developer/reference/config-options.md Updated documentation for migration configuration

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

Copy link
Member

@akshaymankar akshaymankar left a comment

Choose a reason for hiding this comment

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

Thanks for the docs, they look good. I'd say let's move the instances to the right place, other feedback is not so important.

Copy link
Member

@akshaymankar akshaymankar left a comment

Choose a reason for hiding this comment

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

:shipit:

@battermann battermann force-pushed the WPB-22811-migrate-conversation-codes-table-to-postgres-main branch from 08c3234 to b49e039 Compare January 21, 2026 14:39
@battermann battermann force-pushed the WPB-22811-migrate-conversation-codes-table-to-postgres-main branch from b49e039 to 4f14d6f Compare January 22, 2026 08:37
@battermann battermann merged commit a9c1db5 into develop Jan 22, 2026
12 checks passed
@battermann battermann deleted the WPB-22811-migrate-conversation-codes-table-to-postgres-main branch January 22, 2026 11:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ok-to-test Approved for running tests in CI, overrides not-ok-to-test if both labels exist

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants