forked from cyrilgdn/terraform-provider-postgresql
-
Notifications
You must be signed in to change notification settings - Fork 1
feat: Allow to set a database to connect to in a script #43
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
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
bpaquet
reviewed
Oct 22, 2025
…. + script to cleanup tables
Member
Author
|
@bpaquet I added a section on the description but tldr: we should not close the db connection as it may be reused if connecting to the same db. It seems the provider handle this on his side |
GeckoSplinter
previously approved these changes
Oct 22, 2025
bpaquet
reviewed
Oct 22, 2025
bpaquet
approved these changes
Oct 22, 2025
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Add database parameter to postgresql_script resource
Summary
Adds an optional
databaseparameter topostgresql_scriptto specify which database to execute commands in. Defaults to the provider's configured database for backwards compatibility.Changes
databaseschema field (optional, computed)getDatabase()helper and create new connection if neededReadImpl()at end of Create/Update (matches pattern used bypostgresql_schema)Usage
Breaking Changes
None - fully backwards compatible.
FOR REVIEWERS
I did not close explicitely the connection because tests was failling due to
Error: Commands execution failed .... sql: database is closedIt seems that for a DB the provider need to be able to reuse a connection pool that is cached for further operation. So if we close the connection we have issue for further connections