Skip to content

Conversation

@jferrl
Copy link
Contributor

@jferrl jferrl commented Dec 1, 2025

Summary

  • Add support for DML statements (INSERT, UPDATE, DELETE) in Spanner migration files
  • Implement automatic statement type detection using spansql parser
  • Deprecate CleanStatements config flag (now always parses statements)

Changes

New Features

  • DDL statements (CREATE, ALTER, DROP): Executed via UpdateDatabaseDdl API
  • DML INSERT statements: Executed within a read-write transaction
  • Partitioned DML (UPDATE, DELETE): Executed via PartitionedUpdate API for large-scale modifications
  • SQL comments (-- and /* */) are automatically stripped during parsing

Breaking Changes

  • Migration files must contain only one statement type (cannot mix DDL with DML, or INSERT with UPDATE/DELETE)

Deprecations

  • CleanStatements config field is deprecated and ignored
  • x-clean-statements URL parameter is deprecated and ignored

Test plan

  • Unit tests for parseStatements() function (18 test cases)
  • Unit tests for inspectDMLKind() function (6 test cases)
  • Integration tests with example migration files
  • All existing tests pass

References

Implementation based on wrench migration handling.

Closes #135
Closes #775
Closes #918

@jferrl
Copy link
Contributor Author

jferrl commented Dec 1, 2025

@dhui please, could you take a look ? Thanks! 😄

@coveralls
Copy link

Coverage Status

coverage: 54.627% (+0.2%) from 54.432%
when pulling 3ff5793 on jferrl:jferrl-support-dml
into 89e308c on golang-migrate:master.

@jferrl
Copy link
Contributor Author

jferrl commented Dec 1, 2025

After updating to a recent version of spanner client, there a re several open PRs that are no longer needed and issues that can be closed.

@apstndb
Copy link

apstndb commented Dec 18, 2025

This implementation still uses spansql, which is in limited maintenance mode and has many GoogleSQL compatibility issues. Since the core issue in #1194 is the spansql dependency itself, I don't think this PR can close #1194.

@jferrl
Copy link
Contributor Author

jferrl commented Dec 18, 2025

This implementation still uses spansql, which is in limited maintenance mode and has many GoogleSQL compatibility issues. Since the core issue in #1194 is the spansql dependency itself, I don't think this PR can close #1194.

Sorry, my mistake. Removed from PR description.

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.

Support Default on Google Cloud Spanner spanner CHANGE STREAM Support for Spanner DML

4 participants