Skip to content

Commit de055e3

Browse files
Remove collation from update request and make collation non-updatable (#6298) (#4505)
Signed-off-by: Modular Magician <[email protected]>
1 parent 7a806a1 commit de055e3

File tree

3 files changed

+34
-0
lines changed

3 files changed

+34
-0
lines changed

.changelog/6298.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
```release-note:bug
2+
sql: fixed an issue in `google_sql_database_instance` where updates would fail because of the `collation` field
3+
```

google-beta/resource_sql_database_instance.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,7 @@ is set to true.`,
267267
"collation": {
268268
Type: schema.TypeString,
269269
Optional: true,
270+
ForceNew: true,
270271
Description: `The name of server instance collation.`,
271272
},
272273
"database_flags": {
@@ -1305,6 +1306,9 @@ func resourceSqlDatabaseInstanceUpdate(d *schema.ResourceData, meta interface{})
13051306
Settings: expandSqlDatabaseInstanceSettings(d.Get("settings").([]interface{})),
13061307
}
13071308

1309+
// Collation cannot be included in the update request
1310+
instance.Settings.Collation = ""
1311+
13081312
// Lock on the master_instance_name just in case updating any replica
13091313
// settings causes operations on the master.
13101314
if v, ok := d.GetOk("master_instance_name"); ok {

google-beta/resource_sql_database_instance_test.go

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,16 @@ func TestAccSqlDatabaseInstance_basicMSSQL(t *testing.T) {
222222
ImportStateVerify: true,
223223
ImportStateVerifyIgnore: []string{"root_password", "deletion_protection"},
224224
},
225+
{
226+
Config: fmt.Sprintf(
227+
testGoogleSqlDatabaseInstance_update_mssql, databaseName, rootPassword),
228+
},
229+
{
230+
ResourceName: "google_sql_database_instance.instance",
231+
ImportState: true,
232+
ImportStateVerify: true,
233+
ImportStateVerifyIgnore: []string{"root_password", "deletion_protection"},
234+
},
225235
},
226236
})
227237
}
@@ -1221,6 +1231,23 @@ resource "google_sql_database_instance" "instance" {
12211231
}
12221232
`
12231233

1234+
var testGoogleSqlDatabaseInstance_update_mssql = `
1235+
resource "google_sql_database_instance" "instance" {
1236+
name = "%s"
1237+
database_version = "SQLSERVER_2019_STANDARD"
1238+
root_password = "%s"
1239+
deletion_protection = false
1240+
settings {
1241+
tier = "db-custom-1-3840"
1242+
collation = "Polish_CI_AS"
1243+
ip_configuration {
1244+
ipv4_enabled = true
1245+
require_ssl = true
1246+
}
1247+
}
1248+
}
1249+
`
1250+
12241251
func testGoogleSqlDatabaseInstance_ActiveDirectoryConfig(databaseName, networkName, addressRangeName, rootPassword, adDomainName string) string {
12251252
return fmt.Sprintf(`
12261253
data "google_compute_network" "servicenet" {

0 commit comments

Comments
 (0)