From fb88c0221da66bdcaabeaa9c7d7950dc9b5ceb76 Mon Sep 17 00:00:00 2001 From: Cameron Thornton Date: Tue, 19 Jul 2022 15:59:55 -0500 Subject: [PATCH] Remove collation from update request and make collation non-updatable (#6298) --- .../resource_sql_database_instance.go.erb | 4 +++ ...resource_sql_database_instance_test.go.erb | 27 +++++++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/mmv1/third_party/terraform/resources/resource_sql_database_instance.go.erb b/mmv1/third_party/terraform/resources/resource_sql_database_instance.go.erb index ae6f9e24ca55..92841d9e1761 100644 --- a/mmv1/third_party/terraform/resources/resource_sql_database_instance.go.erb +++ b/mmv1/third_party/terraform/resources/resource_sql_database_instance.go.erb @@ -268,6 +268,7 @@ is set to true.`, "collation": { Type: schema.TypeString, Optional: true, + ForceNew: true, Description: `The name of server instance collation.`, }, "database_flags": { @@ -1307,6 +1308,9 @@ func resourceSqlDatabaseInstanceUpdate(d *schema.ResourceData, meta interface{}) Settings: expandSqlDatabaseInstanceSettings(d.Get("settings").([]interface{})), } + // Collation cannot be included in the update request + instance.Settings.Collation = "" + // Lock on the master_instance_name just in case updating any replica // settings causes operations on the master. if v, ok := d.GetOk("master_instance_name"); ok { diff --git a/mmv1/third_party/terraform/tests/resource_sql_database_instance_test.go.erb b/mmv1/third_party/terraform/tests/resource_sql_database_instance_test.go.erb index 487f01a19b9e..af2e92b5a56d 100644 --- a/mmv1/third_party/terraform/tests/resource_sql_database_instance_test.go.erb +++ b/mmv1/third_party/terraform/tests/resource_sql_database_instance_test.go.erb @@ -223,6 +223,16 @@ func TestAccSqlDatabaseInstance_basicMSSQL(t *testing.T) { ImportStateVerify: true, ImportStateVerifyIgnore: []string{"root_password", "deletion_protection"}, }, + { + Config: fmt.Sprintf( + testGoogleSqlDatabaseInstance_update_mssql, databaseName, rootPassword), + }, + { + ResourceName: "google_sql_database_instance.instance", + ImportState: true, + ImportStateVerify: true, + ImportStateVerifyIgnore: []string{"root_password", "deletion_protection"}, + }, }, }) } @@ -1223,6 +1233,23 @@ resource "google_sql_database_instance" "instance" { } ` +var testGoogleSqlDatabaseInstance_update_mssql = ` +resource "google_sql_database_instance" "instance" { + name = "%s" + database_version = "SQLSERVER_2019_STANDARD" + root_password = "%s" + deletion_protection = false + settings { + tier = "db-custom-1-3840" + collation = "Polish_CI_AS" + ip_configuration { + ipv4_enabled = true + require_ssl = true + } + } +} +` + func testGoogleSqlDatabaseInstance_ActiveDirectoryConfig(databaseName, networkName, addressRangeName, rootPassword, adDomainName string) string { return fmt.Sprintf(` data "google_compute_network" "servicenet" {