Skip to content
This repository has been archived by the owner on Jan 17, 2025. It is now read-only.

fix: pq: duplicate key violates unique constraint pg_defacl_name_ind… #139

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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
6 changes: 6 additions & 0 deletions redshift/resource_redshift_default_privileges.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"fmt"
"log"
"strings"
"sync"

"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
Expand All @@ -30,6 +31,8 @@ var defaultPrivilegesObjectTypesCodes = map[string]string{
"table": "r",
}

var defaultPrivilegesMutex sync.Mutex

func redshiftDefaultPrivileges() *schema.Resource {
return &schema.Resource{
Description: `Defines the default set of access privileges to be applied to objects that are created in the future by the specified user. By default, users can change only their own default access privileges. Only a superuser can specify default privileges for other users.`,
Expand Down Expand Up @@ -112,6 +115,9 @@ func resourceRedshiftDefaultPrivilegesDelete(db *DBConnection, d *schema.Resourc
}

func resourceRedshiftDefaultPrivilegesCreate(db *DBConnection, d *schema.ResourceData) error {
defaultPrivilegesMutex.Lock()
defer defaultPrivilegesMutex.Unlock()

privilegesSet := d.Get(defaultPrivilegesPrivilegesAttr).(*schema.Set)
objectType := d.Get(defaultPrivilegesObjectTypeAttr).(string)

Expand Down