Skip to content

Commit

Permalink
Remove collation from update request and make collation non-updatable (
Browse files Browse the repository at this point in the history
…#6298) (#12131)

Signed-off-by: Modular Magician <magic-modules@google.com>
  • Loading branch information
modular-magician authored Jul 19, 2022
1 parent f06f643 commit 6368356
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .changelog/6298.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
sql: fixed an issue in `google_sql_database_instance` where updates would fail because of the `collation` field
```
4 changes: 4 additions & 0 deletions google/resource_sql_database_instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,7 @@ is set to true.`,
"collation": {
Type: schema.TypeString,
Optional: true,
ForceNew: true,
Description: `The name of server instance collation.`,
},
"database_flags": {
Expand Down Expand Up @@ -1305,6 +1306,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 {
Expand Down
27 changes: 27 additions & 0 deletions google/resource_sql_database_instance_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,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"},
},
},
})
}
Expand Down Expand Up @@ -1221,6 +1231,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" {
Expand Down

0 comments on commit 6368356

Please sign in to comment.