terraform-provider-snowflake
terraform-provider-snowflake copied to clipboard
DROP IF EXISTS support
Is your feature request related to a problem? Please describe.
I would like to run separate states where one state I would like to have databases and in the other schemas related to that db. In this case the apply order is from DB to SCHEMA (so first databases are created and then schemas). But in case of destroy the order should be reversed (so destroy schema and then db).
I have my reason why to keep the two states separate, but the order of apply
execution can be just one, so first DB and then SCHEMA. This works fine in case of adding or updating resources. However the destroy fails: the first apply drop the DB but the second apply against schemas tries to drop the schema, what does not exists.
Describe the solution you'd like
There are possibly multiple workaround for this, but of a nice feature would be to enable DROP IF EXISTS for resources, so that the terraform apply in the second stage will not fail if in the time of the resource removal the resource does not exists any more in Snowflake. Maybe a env variable or a resource flag, to ignore if not exists would be a nice solution.
Describe alternatives you've considered
I am also thinking about manually adjusting the state, but that looks more challenging.
Additional context
Add any other context or screenshots about the feature request here.
Old one, but I'd like to see this feature supported specifically for dropping a default schema generated when creating a database, like the PUBLIC
schema
Hey @funes79 👋 As we are currently working on https://github.com/Snowflake-Labs/terraform-provider-snowflake/blob/main/ROADMAP.md#preparing-essential-ga-objects-for-the-provider-v1 resources. The drop if exists will be applied to every refactored resource.
Hey @funes79 👋 The new version (v0.93.0) contains refactored (and new) database resources that use DROP IF EXISTS when they're removed from the state. Closing the ticket as DROP IF EXSITS will be added in every newly refactored resource (refactored schema should be added most likely in the next release, so stay tuned). Thank You for your suggestions!