Revision 9fca0023
Von Moritz Bunkus vor fast 14 Jahren hinzugefügt
sql/Pg-upgrade2-auth/auth_schema_normalization_1.pl | ||
---|---|---|
1 |
#!/usr/bin/perl |
|
2 |
# @tag: auth_schema_normalization_1 |
|
3 |
# @description: Auth-Datenbankschema Normalisierungen Teil 1 |
|
4 |
# @depends: |
|
5 |
|
|
6 |
use strict; |
|
7 |
|
|
8 |
sub do_one { |
|
9 |
my ($dbh, $query) = @_; |
|
10 |
|
|
11 |
if ($dbh->do($query)) { |
|
12 |
$dbh->commit(); |
|
13 |
} else { |
|
14 |
$dbh->rollback(); |
|
15 |
} |
|
16 |
} |
|
17 |
|
|
18 |
sub do_all { |
|
19 |
my $dbh = $::auth->dbconnect(); |
|
20 |
|
|
21 |
my @queries = ( qq|ALTER TABLE auth.group_rights ADD PRIMARY KEY (group_id, "right");|, |
|
22 |
qq|ALTER TABLE auth.user_config ADD PRIMARY KEY (user_id, cfg_key);|, |
|
23 |
qq|ALTER TABLE auth.user_group ADD PRIMARY KEY (user_id, group_id);|); |
|
24 |
|
|
25 |
do_one($dbh, $_) for @queries; |
|
26 |
} |
|
27 |
|
|
28 |
do_all(); |
|
29 |
|
|
30 |
1; |
Auch abrufbar als: Unified diff
Auth-DB-Schema-Normalisierung: Primärschlüssel für Tabellen im auth-Schema