Skip to content
Merged
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
21 changes: 21 additions & 0 deletions postgresql/resource_postgresql_schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,27 @@ func resourcePostgreSQLSchema() *schema.Resource {

func resourcePostgreSQLSchemaCreate(db *DBConnection, d *schema.ResourceData) error {
database := getDatabase(d, db.client.databaseName)

// Try without roles workaround first
txn1, err := startTransaction(db.client, database)
if err != nil {
return err
}
attemptErr := createSchema(db, txn1, d)
if attemptErr == nil {
if err := txn1.Commit(); err == nil {
// Creating worked so we return here
d.SetId(generateSchemaID(d, database))

return resourcePostgreSQLSchemaReadImpl(db, d)
}
}

if err := txn1.Rollback(); err != nil && err != sql.ErrTxDone {
return fmt.Errorf("error rolling back initial schema transaction: %w", err)
}

// Creating without workaround failed so we fallback to use it.
txn, err := startTransaction(db.client, database)
if err != nil {
return err
Expand Down
Loading