Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove collation from update request and make collation non-updatable #12131

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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