Skip to content

Commit

Permalink
make ForceNew on newly added required field (#5362)
Browse files Browse the repository at this point in the history
* make ForceNew on newly added required field

* Update resource_bigquery_table.go

Fixed a typo
  • Loading branch information
edwardmedia authored Oct 27, 2021
1 parent fe708a5 commit 559c661
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions mmv1/third_party/terraform/resources/resource_bigquery_table.go
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,17 @@ func resourceBigQueryTableSchemaIsChangeable(old, new interface{}) (bool, error)
return false, err
}
mapNew := bigQueryArrayToMapIndexedByName(arrayNew)
for key := range mapNew {
// making unchangeable if an newly added column is with REQUIRED mode
if _, ok := mapOld[key]; !ok {
items := mapNew[key].(map[string]interface{})
for k := range items {
if k == "mode" && fmt.Sprintf("%v", items[k]) == "REQUIRED" {
return false, nil
}
}
}
}
for key := range mapOld {
// all old keys should be represented in the new config
if _, ok := mapNew[key]; !ok {
Expand Down

0 comments on commit 559c661

Please sign in to comment.