Repository navigation
fix(account): change social_id primary key in a single ALTER TABLE - #11153
Merged
ArtyomSavchenko merged 1 commit intoOct 19, 2026
Merged
ArtyomSavchenko merged 1 commit into
ArtyomSavchenko merged 1 commit into
Conversation
The account_db_v2_social_id_pk_change migration dropped the social_id primary key and added the new one on _id in two separate ALTER TABLE statements. CockroachDB v25.1+ commits DDL statements individually (autocommit_before_ddl), so the drop is rejected with "primary key dropped without subsequent addition of new primary key in same transaction" and fresh installs cannot finish the account migrations. Drop and add the constraint in one ALTER TABLE statement, which both CockroachDB and PostgreSQL support with the same resulting schema. Databases that already applied the migration are unaffected because migrations are tracked by identifier; installs stuck on the failed migration pick up the new DDL on the next retry. Fixes hcengineering#9963 Signed-off-by: Michael Uray <michaeluray@users.noreply.github.com>
ArtyomSavchenko
approved these changes
Oct 19, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #9963
Problem and change
The account_db_v2_social_id_pk_change migration dropped the social_id
primary key and added the new one on _id in two separate ALTER TABLE
statements. CockroachDB v25.1+ commits DDL statements individually
(autocommit_before_ddl), so the drop is rejected with "primary key
dropped without subsequent addition of new primary key in same
transaction" and fresh installs cannot finish the account migrations.
Drop and add the constraint in one ALTER TABLE statement, which both
CockroachDB and PostgreSQL support with the same resulting schema.
Databases that already applied the migration are unaffected because
migrations are tracked by identifier; installs stuck on the failed
migration pick up the new DDL on the next retry.
Tests
New unit test
server/account/src/__tests__/migrations.test.ts(the primary-key change is a single statement for Postgres and CockroachDB). The migration runner keys migrations by id, so databases that already applied it are unaffected; a database stuck on the failing statement retries with the new SQL.