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
  • Loading branch information
c2thorn authored Jul 19, 2022
1 parent 32aa7cf commit fb88c02
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"},
},
},
})
}
Expand Down Expand Up @@ -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" {
Expand Down

0 comments on commit fb88c02

Please sign in to comment.