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

make ForceNew on newly added required field #10421

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/5362.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
bigquery: fixed a bug of cannot add required fields to an existing schema on `google_bigquery_table`
```
11 changes: 11 additions & 0 deletions google/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
2 changes: 1 addition & 1 deletion google/resource_container_node_pool.go
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
package google

import (
"context"
"fmt"
"log"
"regexp"
"strings"
"time"

"github.com/hashicorp/terraform-plugin-sdk/v2/helper/customdiff"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
Expand Down