I recently discovered that Google Cloud SQL v2 now supports App Engine standard runtime. This is very exciting for me. I wanted to try out the process and make sure there were no gotchas.
- I created a new Cloud SQL v2 instance.
- I used my syncing script from my blog post Migrating between Cloud SQL databases to move the data to the new instance.
- I created a new App Engine module by store a new version of my app using the old code base.
- I changed the connection string from the old database to the new one. The pattern to make this happen has changed a bit, more down below.
- That was it. The new code served up just fine. I served up on the old module until I made the connection string config tweak to the old code base.
New connection string
The new connection strings are only a little different than the old ones, and should require just a change to one string in your config.
The directions will tell you to look for your Instance connection name in the Instance properties of your Cloud SQL Developer Console. There are two patterns that these strings come in.
- V1 connection names follow the pattern projectid:instancename
- V2 connection names follow the pattern projectid:regionname:instancename.
It’s a pretty simple change, but I can see someone accidentally (or willfully) not reading the documentation and getting tripped up on this. The new connection strings require region name; that’s all there is to it. I’ve tested this on PHP. I assume it works everywhere. But your mileage may vary. Golang tests are coming soon; I will update when I make that change.