From 1b8c793fbb18e71f62b935697d2dd514bb2d9cef Mon Sep 17 00:00:00 2001 From: Edward Sun Date: Fri, 22 Oct 2021 10:29:58 -0700 Subject: [PATCH 1/2] make ForceNew on newly added required field --- .../terraform/resources/resource_bigquery_table.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/mmv1/third_party/terraform/resources/resource_bigquery_table.go b/mmv1/third_party/terraform/resources/resource_bigquery_table.go index 4a8bd4e6625d..128002f4c2ec 100644 --- a/mmv1/third_party/terraform/resources/resource_bigquery_table.go +++ b/mmv1/third_party/terraform/resources/resource_bigquery_table.go @@ -225,6 +225,17 @@ func resourceBigQueryTableSchemaIsChangeable(old, new interface{}) (bool, error) return false, err } mapNew := bigQueryArrayToMapIndexedByName(arrayNew) + for key := range mapNew { + // making inchnagable 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 { From bde4224442c253b9086b5b3d4ed1464926234928 Mon Sep 17 00:00:00 2001 From: Edward Sun <42220489+edwardmedia@users.noreply.github.com> Date: Tue, 26 Oct 2021 11:39:37 -0700 Subject: [PATCH 2/2] Update resource_bigquery_table.go Fixed a typo --- mmv1/third_party/terraform/resources/resource_bigquery_table.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mmv1/third_party/terraform/resources/resource_bigquery_table.go b/mmv1/third_party/terraform/resources/resource_bigquery_table.go index 128002f4c2ec..1b7acd7f8cd7 100644 --- a/mmv1/third_party/terraform/resources/resource_bigquery_table.go +++ b/mmv1/third_party/terraform/resources/resource_bigquery_table.go @@ -226,7 +226,7 @@ func resourceBigQueryTableSchemaIsChangeable(old, new interface{}) (bool, error) } mapNew := bigQueryArrayToMapIndexedByName(arrayNew) for key := range mapNew { - // making inchnagable if an newly added column is with REQUIRED mode + // 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 {