How to manage schema changes to a BigQuery table via Terraform

8k Views Asked by At

We currently use the following mechanism to create a BigQuery table with a pre-defined schema and we created the infrastructure.

https://www.terraform.io/docs/providers/google/r/bigquery_table.html

The dev team decided to modify the schema by adding another column, so we are planning to modify the schema changes in the above terraform script to enable this.

What would be the best way to manage such schema migrations in production environments?

Since in a production environment, we would be expected to retain the table data while the schema migration is performed

2

There are 2 best solutions below

0
Pawan Sharma On

It seems you cannot modify the schema of the table and retain data using Terraform. Instead you can use bq command-line for the same. https://cloud.google.com/bigquery/docs/managing-table-schemas#bq.

1
workingclassheroine On