Skip to content

sql/schemachanger: add ALTER SEQUENCE to declarative schema changer#162634

Draft
rafiss wants to merge 1 commit intocockroachdb:masterfrom
rafiss:dsc-alter-sequence
Draft

sql/schemachanger: add ALTER SEQUENCE to declarative schema changer#162634
rafiss wants to merge 1 commit intocockroachdb:masterfrom
rafiss:dsc-alter-sequence

Conversation

@rafiss
Copy link
Collaborator

@rafiss rafiss commented Feb 7, 2026

This commit adds ALTER SEQUENCE support to the declarative schema changer. The implementation follows the same pattern as ALTER TABLE ALTER COLUMN ... SET/DROP IDENTITY, which already manipulates SequenceOption, SequenceValue, and SequenceOwner elements for identity-backing sequences. All existing elements and operations are reused - no new proto definitions are needed.

The builder handles all ALTER SEQUENCE options: INCREMENT, MINVALUE, MAXVALUE, START, RESTART, CACHE (node and session), AS type changes (with implicit bounds adjustment), VIRTUAL, OWNED BY, OWNED BY NONE, and IF EXISTS. It is gated behind the V26_2 version check to ensure mixed-version compatibility.

Epic: CRDB-31169
Release note: None

This commit adds ALTER SEQUENCE support to the declarative schema
changer. The implementation follows the same pattern as ALTER TABLE
ALTER COLUMN ... SET/DROP IDENTITY, which already manipulates
SequenceOption, SequenceValue, and SequenceOwner elements for
identity-backing sequences. All existing elements and operations are
reused - no new proto definitions are needed.

The builder handles all ALTER SEQUENCE options: INCREMENT, MINVALUE,
MAXVALUE, START, RESTART, CACHE (node and session), AS type changes
(with implicit bounds adjustment), VIRTUAL, OWNED BY, OWNED BY NONE,
and IF EXISTS. It is gated behind the V26_2 version check to ensure
mixed-version compatibility.

Epic: CRDB-31169
Release note: None
@trunk-io
Copy link
Contributor

trunk-io bot commented Feb 7, 2026

Merging to master in this repository is managed by Trunk.

  • To merge this pull request, check the box to the left or comment /trunk merge below.

@cockroach-teamcity
Copy link
Member

This change is Reviewable

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