Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion postgresql/resource_postgresql_subscription.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,13 @@ func resourcePostgreSQLSubscription() *schema.Resource {
Description: "Name of the replication slot to use. The default behavior is to use the name of the subscription for the slot name",
ValidateFunc: validation.StringIsNotEmpty,
},
"enabled": {
Type: schema.TypeBool,
Optional: true,
ForceNew: true,
Default: true,
Description: "Specifies whether the subscription should be actively replicating or whether it should just be set up but not started yet. The default is true.",
},
},
}
}
Expand Down Expand Up @@ -312,8 +319,9 @@ func getOptionalParameters(d *schema.ResourceData) string {

createSlot, okCreate := d.GetOkExists("create_slot") //nolint:staticcheck
slotName, okName := d.GetOk("slot_name")
enabled, okEnabled := d.GetOk("enabled")

if !okCreate && !okName {
if !okCreate && !okName && !okEnabled {
// use default behavior, no WITH statement
return ""
}
Expand All @@ -325,6 +333,9 @@ func getOptionalParameters(d *schema.ResourceData) string {
if okName {
params = append(params, fmt.Sprintf("%s = %s", "slot_name", pq.QuoteLiteral(slotName.(string))))
}
if okEnabled {
params = append(params, fmt.Sprintf("%s = %t", "enabled", enabled.(bool)))
}

returnValue = fmt.Sprintf(parameterSQLTemplate, strings.Join(params, ", "))
return returnValue
Expand Down