Auth-DB-Schema-Normalisierung: Primärschlüssel für Tabellen im auth-Schema
authorMoritz Bunkus <m.bunkus@linet-services.de>
Thu, 30 Dec 2010 14:23:17 +0000 (15:23 +0100)
committerMoritz Bunkus <m.bunkus@linet-services.de>
Thu, 30 Dec 2010 14:23:17 +0000 (15:23 +0100)
sql/Pg-upgrade2-auth/auth_schema_normalization_1.pl [new file with mode: 0644]

diff --git a/sql/Pg-upgrade2-auth/auth_schema_normalization_1.pl b/sql/Pg-upgrade2-auth/auth_schema_normalization_1.pl
new file mode 100644 (file)
index 0000000..78726cc
--- /dev/null
@@ -0,0 +1,30 @@
+#!/usr/bin/perl
+# @tag: auth_schema_normalization_1
+# @description: Auth-Datenbankschema Normalisierungen Teil 1
+# @depends:
+
+use strict;
+
+sub do_one {
+  my ($dbh, $query) = @_;
+
+  if ($dbh->do($query)) {
+    $dbh->commit();
+  } else {
+    $dbh->rollback();
+  }
+}
+
+sub do_all {
+  my $dbh = $::auth->dbconnect();
+
+  my @queries = ( qq|ALTER TABLE auth.group_rights ADD PRIMARY KEY (group_id, "right");|,
+                  qq|ALTER TABLE auth.user_config  ADD PRIMARY KEY (user_id,  cfg_key);|,
+                  qq|ALTER TABLE auth.user_group   ADD PRIMARY KEY (user_id,  group_id);|);
+
+  do_one($dbh, $_) for @queries;
+}
+
+do_all();
+
+1;