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

Added a check during the postgresql_extension to prevent multiple resources from being created for the one extension #426

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

timtatt
Copy link

@timtatt timtatt commented Mar 31, 2024

To address [#304] where users are implementing multiple extension resources per extension under the assumption one is required per schema. According to postgres documentation, schema is only the location to install the extensions objects.

Changes:

  • Updated the README to describe running the provider in a local environment
  • Added a check during the postgresql_extension to prevent multiple resources from being created for the one extension
  • Updated documentation to deter users from creating the same extension across multiple schemas
resource "postgresql_extension" "schema2" {
  name = "pg_stat_statements"
  schema = "schema2"
}

resource "postgresql_extension" "schema1" {
  name = "pg_stat_statements"
  schema = "schema1"
}

Prior: both resources created, each apply will ALTER the schema of the extension.
Now: one resource will be created and the other will error eg.

Error: extension 'pg_stat_statements' already exists under schema 'schema1'

Projects which contain multiple resources for the same extension will still experience the same behaviour akin to importing a resource into two places. However, new resources created will be unable to do so if the extension exists. A note in the upgrade docs should mention to terraform state rm places where extensions have been duplicated

update the documentation to deter usersfrom creating one extension per schema
@timtatt timtatt changed the title Added a check during the postgresql_extension to prevent multiple resources from being created for the one schema Added a check during the postgresql_extension to prevent multiple resources from being created for the one extension Mar 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant