Skip to content

feature(spanner): Implement DML Support for Spanner#1197

Open
jtwatson wants to merge 6 commits intogolang-migrate:masterfrom
jtwatson:feature/spanner-client-enhancements
Open

feature(spanner): Implement DML Support for Spanner#1197
jtwatson wants to merge 6 commits intogolang-migrate:masterfrom
jtwatson:feature/spanner-client-enhancements

Conversation

@jtwatson
Copy link
Copy Markdown

@jtwatson jtwatson commented Nov 29, 2024

Closes #135
Closes #775
Closes #918
Closes #1194

Supersedes the following PRs #733, #910, #924, #1287

  1. This PR implements DML support and uses the memefish lexer to parse the migrations, replacing the usage of the spansql package. As a result, numerous other spansql related issues have been resolved.

    The following features have been implemented:

    1. DML support
    2. Ability to put multiple statements in a single migration script
    3. Ability to include comments in the migration scripts
    4. Ability to mix DDL and DML in the same migration script

    To maintain backward compatibility, the x-clean-statements option must be used to enable the above features.

  2. This PR also fixes a bug where a provided spanner client via WithInstance() is closed when Migration.Close() is called. According to Docs, the caller is responsible for closing the underlying database client. This fix brings the Spanner driver into compliance with the expected behavior.

I am maintaining a fork with this fix for those who would like to use it.

Put the following replace directive you your projects go.mod

replace github.com/golang-migrate/migrate/v4 v4.19.1 => github.com/jtwatson/migrate/v4 v4.19.2-beta.0

@jtwatson jtwatson force-pushed the feature/spanner-client-enhancements branch from c60aa87 to be12225 Compare November 29, 2024 06:35
@jtwatson jtwatson changed the title feature: Implement DML Support for Spanner feature(spanner): Implement DML Support for Spanner Nov 29, 2024
@jtwatson
Copy link
Copy Markdown
Author

jtwatson commented Nov 29, 2024

@dhui

This PR supersedes the following PR #733, #910, #924

It is a robust implementation that greatly improves support for Spanner migrations. It also fixes a lot of open issues with the existing DDL parsing implementation.

NOTE: Not sure why tests are failing, but it is not related to spanner tests. It looks like cockroachdb is having an issue.

@apstndb
Copy link
Copy Markdown

apstndb commented Jan 9, 2025

FYI: Now memefish has official release, so you don't need to use v0.0.0 pseudo version.

@jtwatson
Copy link
Copy Markdown
Author

@dhui
Can you take a look at this PR, please? The community will benefit from it.

@coveralls
Copy link
Copy Markdown

coveralls commented Feb 5, 2025

Coverage Status

coverage: 54.624% (+0.2%) from 54.432%
when pulling 810ea7e on jtwatson:feature/spanner-client-enhancements
into 89e308c on golang-migrate:master.

@minhnnhat
Copy link
Copy Markdown

Hello, any update on this feature ?

@jtwatson
Copy link
Copy Markdown
Author

@dhui

Will you please take a look at this PR? It has been well tested and is in production use, so would be nice to get it merged!

@apstndb
Copy link
Copy Markdown

apstndb commented Apr 4, 2025

@dhui
FYI:

googleapis/google-cloud-go#11941

spansql package is going to be already marked as "limited maintenance mode" because

it is not actively maintained by the core team

Almost all of the issues with Spanner in golang-migrate are caused by spansql. What is the reason for not responding to this PR?

@jtwatson
Copy link
Copy Markdown
Author

jtwatson commented May 8, 2025

@dhui

Rebased onto master branch and all tests look good.

I would love to get a review on this!

@jtwatson jtwatson force-pushed the feature/spanner-client-enhancements branch from 548bc4c to 4819a3a Compare May 19, 2025 16:00
@jtwatson jtwatson force-pushed the feature/spanner-client-enhancements branch from 4819a3a to 85cce1e Compare September 18, 2025 01:52
@jtwatson
Copy link
Copy Markdown
Author

@dhui

Rebased onto master branch and all tests look good.

I would love to get a review on this!

@jtwatson jtwatson force-pushed the feature/spanner-client-enhancements branch from 85cce1e to 810ea7e Compare December 3, 2025 23:28
@jtwatson
Copy link
Copy Markdown
Author

jtwatson commented Jan 23, 2026

@dhui @Fontinalis
I guess I've reached the point where I no longer believe anyone with the ability to merge this work will ever take a look at my PR. This is unfortunate, as the current support for Spanner is unusable for most people.

I am planning to fork this lib and go in a different direction. If you happen to see this and want to help, please reach out. It would be much better if we kept our efforts focused rather than fragmenting.

@RichardLiInReazon
Copy link
Copy Markdown

@dhui
Can we please have a look at this PR?
This will be essential for using this lib with Spanner.
Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

7 participants