[pmg-devel] [PATCH pmg-api 5/8] feature: match groups: add field to database
Leo Nunner
l.nunner at proxmox.com
Fri Apr 7 15:42:51 CEST 2023
Adds a 'MatchGroup' field to the 'RuleGroup' table.
Signed-off-by: Leo Nunner <l.nunner at proxmox.com>
---
src/PMG/DBTools.pm | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/src/PMG/DBTools.pm b/src/PMG/DBTools.pm
index 07d39b1..e038365 100644
--- a/src/PMG/DBTools.pm
+++ b/src/PMG/DBTools.pm
@@ -408,6 +408,7 @@ sub create_ruledb {
Rule_ID INTEGER NOT NULL,
Grouptype INTEGER NOT NULL,
Negate INTEGER NOT NULL DEFAULT 0,
+ MatchGroup INTEGER NOT NULL DEFAULT 0,
PRIMARY KEY (Objectgroup_ID, Rule_ID, Grouptype)
);
@@ -583,6 +584,19 @@ sub upgradedb {
}
}
+ # Allow logical AND for rule objects
+ if (!database_column_exists($dbh, 'RuleGroup', 'MatchGroup')) {
+ eval {
+ $dbh->begin_work;
+ $dbh->do("ALTER TABLE RuleGroup ADD COLUMN MatchGroup INTEGER NOT NULL DEFAULT 0");
+ $dbh->commit;
+ };
+ if (my $err = $@) {
+ $dbh->rollback;
+ die $err;
+ }
+ }
+
foreach my $table (keys %$tables) {
eval { $dbh->do("ANALYZE $table"); };
warn $@ if $@;
--
2.30.2
More information about the pmg-devel
mailing list