https://pulumi.com logo
#getting-started
Title
# getting-started
r

rough-oyster-77458

04/05/2022, 7:11 PM
Hi, I want to change a schema in my Bigquery table. I know that it should be deleted and I'm ok with it. I changed the schema and when I run
pulumi up
, I see this error message:
Copy code
error: deleting urn:pulumi:dev::data::gcp:bigquery/dataset:Dataset$gcp:bigquery/table:Table::my_dataset.my_table: 1 error occurred:
        * cannot destroy instance without setting deletion_protection=false and running `terraform apply`
I changes some resource options:
Copy code
opts=pl.ResourceOptions(
        parent=dataset_raw,
        delete_before_replace=True,
        protect=False,
    )
But the error has not been dissapeared. What did I do wrong? How to fix that?
s

shy-arm-32391

04/05/2022, 7:42 PM
Hi Viktor - I believe the input you want to explicitly set is here: https://www.pulumi.com/registry/packages/gcp/api-docs/sql/databaseinstance/#deletionprotection_nodejs and there's a note in the top description that covers your experience, I believe: https://www.pulumi.com/registry/packages/gcp/api-docs/sql/databaseinstance/#databaseinstance
r

rough-oyster-77458

04/05/2022, 8:16 PM
Hi @shy-arm-32391 I use Bigquery, not Cloud SQL. Your link about is about Cloud SQL. But maybe there is a same thing, I'm going to check. I use this resource: https://www.pulumi.com/registry/packages/gcp/api-docs/bigquery/
s

shy-arm-32391

04/05/2022, 8:25 PM
ah, my bad! it does seem that it is the same: https://www.pulumi.com/registry/packages/gcp/api-docs/bigquery/table/
I hope that helps! 🙂
r

rough-oyster-77458

04/05/2022, 9:15 PM
It works! When combined with
delete_before_replace=True
. Thanks so much!
b

breezy-glass-7721

06/23/2022, 4:22 PM
Hi guys, sorry to chime in that topic but I couldn’t get answer from other channels. @rough-oyster-77458, Do you know if there is a way to add columns a table in Bigquery without recreate table and not touching the underlying data?
r

rough-oyster-77458

06/23/2022, 6:26 PM
Hi @breezy-glass-7721 No problem. I use
pulumi_gcp.bigquery.Table
object to create and update tables. It consumes
schema
parameter to control the schema, where we should put a JSON string with a schema. When I just add a new column schema to the JSON, it creates a new column in the existing table without recreating the table. And it works pretty fine for me. But if you want to change a column (for example, when you decide you want to change
user_id
field type from STRING to INT), I'm afraid Pulumi will recreate the whole table. And this is a limitation of Bigquery, as well as most other column oriented data bases. It's not a limitation of Pulumi.
b

breezy-glass-7721

06/23/2022, 7:03 PM
Thank you so much Viktor! It is really helpful
We use native api for GCP. Does it make difference?
r

rough-oyster-77458

09/05/2022, 7:37 AM
Not much, I guess
But be careful - the native provider is not stable
9 Views