mattes / migrate

Database migrations. CLI and Golang library.
Other
2.29k stars 326 forks source link

Add Spanner driver #251

Closed christianklotz closed 7 years ago

christianklotz commented 7 years ago

Closes #172.

Implementation

Follows for most parts the guide at https://cloud.google.com/spanner/docs/getting-started/go.

The database URL must be provided in the following format.

spanner://projects/P/instances/I/databases/DB

Sample migrations based on the PostgreSQL examples are included, too. The naming convention – according to Google's sample code – seems to be PascalCasing/UpperCamelCase which has been applied to table and column names.

Testing

Google Spanner is exclusive to Google Cloud Platform and doesn't currently offer a self-hosting option. Hence, a SPANNER_DATABASE environment variable is expected to run the test which is also the reason why I didn't use the Docker approach for testing.

Note: To run a database instance you'll need to sign-up for the free trial or add an instance to an existing, billable project.

mattes commented 7 years ago

this is awesome!

christianklotz commented 7 years ago

Looking at the failed test I wonder if it should simply skip the test if SPANNER_DATABASE isn't set? Currently it just skips it on tests being run with the short flag and therefor results in the following message.

database name "" should conform to pattern "^projects/[^/]+/instances/[^/]+/databases/[^/]+$"
exit status 1
FAIL    github.com/mattes/migrate/database/spanner  0.024s

Since there's no public Spanner instance nor a way to run Spanner within a Docker container I don't really see how we could test it with Travis. What do you think?

mattes commented 7 years ago

yeah, that sounds good to me. maybe we can add a comment in the readme.