Skip to content

Conversation

@jBouyoud
Copy link

@jBouyoud jBouyoud commented Jan 7, 2026

Description

This PR adds support for database-level configuration parameters to the postgresql_database resource, similar to what was implemented for roles in commit f625d09.

Changes

Core Implementation (resource_postgresql_database.go)

  • Added parameter block to database schema with name, value, and quote attributes
  • Implemented readDatabaseParameters() to read parameters from pg_database.datconfig
  • Implemented setDatabaseConfigurationParameters() to apply changes via ALTER DATABASE SET/RESET
  • Updated resourcePostgreSQLDatabaseReadImpl() to read parameters
  • Updated resourcePostgreSQLDatabaseUpdate() to set parameters

Tests (resource_postgresql_database_test.go)

  • Added TestAccPostgresqlDatabase_Parameters test covering:
    • Database creation with multiple parameters
    • Parameter updates and deletions
  • Added testAccCheckDatabaseParameter() helper function

Documentation

  • Updated website/docs/r/postgresql_database.html.markdown with:
    • Usage examples with parameter blocks
    • Complete documentation in "Argument Reference" section
  • Added examples/database-with-parameters/ with practical examples

Usage Example

resource "postgresql_database" "my_db" {
  name = "my_db"

  parameter {
    name  = "work_mem"
    value = "16MB"
    quote = false
  }

  parameter {
    name  = "max_parallel_workers"
    value = "4"
    quote = false
  }
}

Generated SQL

Set parameter

ALTER DATABASE my_db SET work_mem TO 16MB;

Reset parameter

ALTER DATABASE my_db RESET work_mem;

Compatibility

  • Compatible with all PostgreSQL versions supported by the provider
  • Database-level configuration parameters are available since PostgreSQL 9.0+

(cherry picked from commit 9767a29)
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