Add SEQUENCE support (CREATE/ALTER/DROP)#83
Open
tomoemon wants to merge 1 commit intodaichirata:masterfrom
Open
Add SEQUENCE support (CREATE/ALTER/DROP)#83tomoemon wants to merge 1 commit intodaichirata:masterfrom
tomoemon wants to merge 1 commit intodaichirata:masterfrom
Conversation
Add support for Cloud Spanner SEQUENCE statements in diff, apply, create, and export commands. Sequences are created before tables and dropped after tables to respect dependency ordering. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
apstndb
reviewed
Feb 20, 2026
Comment on lines
+1374
to
+1380
| // If params changed, we need DROP + CREATE | ||
| if !g.sequenceParamsEqual(from.Params, to.Params) { | ||
| ddl.Append(&ast.DropSequence{Name: from.Name}) | ||
| ddl.Append(to.CreateSequence) | ||
| g.droppedSequence = append(g.droppedSequence, identsToComparable(from.Name.Idents...)) | ||
| return ddl | ||
| } |
There was a problem hiding this comment.
I think ast.SequenceParam can be translated into
- RestartCounterWith
- SkipRange
- NoSkipRange
https://pkg.go.dev/github.com/cloudspannerecosystem/memefish@v0.6.2/ast#AlterSequence
DROP and CREATE sequence is not safe operation because sequences maintain their states. If it is needed, flag like --allow-recreate may be considerable choice. It is same as spanner-schema-diff-tool
By default, changes to indexes will also cause a failure. The
--allowRecreateIndexes command line option enables index changes by
generating statements to drop and recreate the index.
By default, changes to foreign key constraints will also cause a failure. The
--allowRecreateForeignKeys command line option enables foreign key changes by
generating statements to drop and recreate the constraint.
--allowDropStatements Enables output of DROP commands to delete
columns, tables or indexes not used in the
new DDL file.
--allowRecreateForeignKeys Allows dropping and recreating Foreign Keys
(and their backing Indexes) to apply changes.
--allowRecreateIndexes Allows dropping and recreating secondary
Indexes to apply changes.
Author
There was a problem hiding this comment.
Thank you for the comment. I agree with your point. I'll also check the specification of spanner-schema-diff-tool that you mentioned.
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.
If there is any reason not to support sequences, I would appreciate it if you could let me know.
Summary
CREATE SEQUENCE,ALTER SEQUENCE,DROP SEQUENCEstatements--ignore-sequencesflag todiff,apply,create,exportcommandsTests
go test ./internal/hammer/...all passgo run . diff /dev/null db.sqlcorrectly outputs SEQUENCEgo run . diff spanner://... db.sqlcompletes without error🤖 Generated with Claude Code