Skip to content

Commit 20144ac

Browse files
author
Dmitry Mischenko
authored
Add new resource: postgresql_publication (#192)
1 parent ec08867 commit 20144ac

File tree

7 files changed

+1473
-0
lines changed

7 files changed

+1473
-0
lines changed

postgresql/config.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@ const (
3434
featurePrivilegesOnSchemas
3535
featureForceDropDatabase
3636
featurePid
37+
featurePublishViaRoot
38+
featurePubTruncate
39+
featurePublication
40+
featurePubWithoutTruncate
3741
featureFunction
3842
)
3943

@@ -88,6 +92,17 @@ var (
8892
// for Postgresql >= 9.2 and above
8993
featurePid: semver.MustParseRange(">=9.2.0"),
9094

95+
// attribute publish_via_partition_root for partition is supported
96+
featurePublishViaRoot: semver.MustParseRange(">=13.0.0"),
97+
98+
// attribute pubtruncate for publications is supported
99+
featurePubTruncate: semver.MustParseRange(">=11.0.0"),
100+
101+
// attribute pubtruncate for publications is supported
102+
featurePubWithoutTruncate: semver.MustParseRange("<11.0.0"),
103+
104+
// publication is Supported
105+
featurePublication: semver.MustParseRange(">=10.0.0"),
91106
// We do not support CREATE FUNCTION for Postgresql < 8.4
92107
featureFunction: semver.MustParseRange(">=8.4.0"),
93108
}

postgresql/helpers.go

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -476,3 +476,29 @@ func pgLockRole(txn *sql.Tx, role string) error {
476476

477477
return nil
478478
}
479+
480+
func arrayDifference(a, b []interface{}) (diff []interface{}) {
481+
m := make(map[interface{}]bool)
482+
483+
for _, item := range b {
484+
m[item] = true
485+
}
486+
487+
for _, item := range a {
488+
if _, ok := m[item]; !ok {
489+
diff = append(diff, item)
490+
}
491+
}
492+
return
493+
}
494+
495+
func isUniqueArr(arr []interface{}) (interface{}, bool) {
496+
keys := make(map[interface{}]bool, len(arr))
497+
for _, entry := range arr {
498+
if _, value := keys[entry]; value {
499+
return entry, false
500+
}
501+
keys[entry] = true
502+
}
503+
return nil, true
504+
}

postgresql/provider.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,7 @@ func Provider() *schema.Provider {
161161
"postgresql_grant": resourcePostgreSQLGrant(),
162162
"postgresql_grant_role": resourcePostgreSQLGrantRole(),
163163
"postgresql_replication_slot": resourcePostgreSQLReplicationSlot(),
164+
"postgresql_publication": resourcePostgreSQLPublication(),
164165
"postgresql_physical_replication_slot": resourcePostgreSQLPhysicalReplicationSlot(),
165166
"postgresql_schema": resourcePostgreSQLSchema(),
166167
"postgresql_role": resourcePostgreSQLRole(),

0 commit comments

Comments
 (0)