From d2c5f6474ebd578ce46e09484780cfea556abb5e Mon Sep 17 00:00:00 2001 From: Moritz Bunkus Date: Mon, 14 Dec 2015 13:33:23 +0100 Subject: [PATCH] rose_auto_create_model.pl: --all behandelt auch auth-Tabellen --- SL/DB/AuthMasterRight.pm | 13 ++++++++++ SL/DB/AuthSchemaInfo.pm | 13 ++++++++++ SL/DB/AuthSession.pm | 13 ++++++++++ SL/DB/AuthSessionContent.pm | 13 ++++++++++ SL/DB/Helper/Mappings.pm | 4 +++ SL/DB/Manager/AuthMasterRight.pm | 14 +++++++++++ SL/DB/Manager/AuthSchemaInfo.pm | 14 +++++++++++ SL/DB/Manager/AuthSession.pm | 14 +++++++++++ SL/DB/Manager/AuthSessionContent.pm | 14 +++++++++++ SL/DB/MetaSetup/AuthClient.pm | 12 ++++----- SL/DB/MetaSetup/AuthClientGroup.pm | 4 +-- SL/DB/MetaSetup/AuthClientUser.pm | 4 +-- SL/DB/MetaSetup/AuthGroup.pm | 6 ++--- SL/DB/MetaSetup/AuthGroupRight.pm | 6 ++--- SL/DB/MetaSetup/AuthMasterRight.pm | 25 +++++++++++++++++++ SL/DB/MetaSetup/AuthSchemaInfo.pm | 23 +++++++++++++++++ SL/DB/MetaSetup/AuthSession.pm | 22 ++++++++++++++++ SL/DB/MetaSetup/AuthSessionContent.pm | 22 ++++++++++++++++ SL/DB/MetaSetup/AuthUser.pm | 4 +-- SL/DB/MetaSetup/AuthUserConfig.pm | 6 ++--- SL/DB/MetaSetup/AuthUserGroup.pm | 6 ++--- scripts/rose_auto_create_model.pl | 20 +++++++++++++-- .../session_content_primary_key.sql | 4 +++ 23 files changed, 242 insertions(+), 34 deletions(-) create mode 100644 SL/DB/AuthMasterRight.pm create mode 100644 SL/DB/AuthSchemaInfo.pm create mode 100644 SL/DB/AuthSession.pm create mode 100644 SL/DB/AuthSessionContent.pm create mode 100644 SL/DB/Manager/AuthMasterRight.pm create mode 100644 SL/DB/Manager/AuthSchemaInfo.pm create mode 100644 SL/DB/Manager/AuthSession.pm create mode 100644 SL/DB/Manager/AuthSessionContent.pm create mode 100644 SL/DB/MetaSetup/AuthMasterRight.pm create mode 100644 SL/DB/MetaSetup/AuthSchemaInfo.pm create mode 100644 SL/DB/MetaSetup/AuthSession.pm create mode 100644 SL/DB/MetaSetup/AuthSessionContent.pm create mode 100644 sql/Pg-upgrade2-auth/session_content_primary_key.sql diff --git a/SL/DB/AuthMasterRight.pm b/SL/DB/AuthMasterRight.pm new file mode 100644 index 000000000..c92bd0e8d --- /dev/null +++ b/SL/DB/AuthMasterRight.pm @@ -0,0 +1,13 @@ +# This file has been auto-generated only because it didn't exist. +# Feel free to modify it at will; it will not be overwritten automatically. + +package SL::DB::AuthMasterRight; + +use strict; + +use SL::DB::MetaSetup::AuthMasterRight; +use SL::DB::Manager::AuthMasterRight; + +__PACKAGE__->meta->initialize; + +1; diff --git a/SL/DB/AuthSchemaInfo.pm b/SL/DB/AuthSchemaInfo.pm new file mode 100644 index 000000000..93a631c16 --- /dev/null +++ b/SL/DB/AuthSchemaInfo.pm @@ -0,0 +1,13 @@ +# This file has been auto-generated only because it didn't exist. +# Feel free to modify it at will; it will not be overwritten automatically. + +package SL::DB::AuthSchemaInfo; + +use strict; + +use SL::DB::MetaSetup::AuthSchemaInfo; +use SL::DB::Manager::AuthSchemaInfo; + +__PACKAGE__->meta->initialize; + +1; diff --git a/SL/DB/AuthSession.pm b/SL/DB/AuthSession.pm new file mode 100644 index 000000000..daf305e20 --- /dev/null +++ b/SL/DB/AuthSession.pm @@ -0,0 +1,13 @@ +# This file has been auto-generated only because it didn't exist. +# Feel free to modify it at will; it will not be overwritten automatically. + +package SL::DB::AuthSession; + +use strict; + +use SL::DB::MetaSetup::AuthSession; +use SL::DB::Manager::AuthSession; + +__PACKAGE__->meta->initialize; + +1; diff --git a/SL/DB/AuthSessionContent.pm b/SL/DB/AuthSessionContent.pm new file mode 100644 index 000000000..1443e7073 --- /dev/null +++ b/SL/DB/AuthSessionContent.pm @@ -0,0 +1,13 @@ +# This file has been auto-generated only because it didn't exist. +# Feel free to modify it at will; it will not be overwritten automatically. + +package SL::DB::AuthSessionContent; + +use strict; + +use SL::DB::MetaSetup::AuthSessionContent; +use SL::DB::Manager::AuthSessionContent; + +__PACKAGE__->meta->initialize; + +1; diff --git a/SL/DB/Helper/Mappings.pm b/SL/DB/Helper/Mappings.pm index 976dfa742..5eb9a5a3f 100644 --- a/SL/DB/Helper/Mappings.pm +++ b/SL/DB/Helper/Mappings.pm @@ -89,6 +89,10 @@ my %kivitendo_package_names = ( 'auth.clients_groups' => 'auth_client_group', 'auth.group' => 'auth_group', 'auth.group_rights' => 'auth_group_right', + 'auth.master_rights' => 'auth_master_right', + 'auth.schema_info' => 'auth_schema_info', + 'auth.session' => 'auth_session', + 'auth.session_content' => 'auth_session_content', 'auth.user' => 'auth_user', 'auth.user_config' => 'auth_user_config', 'auth.user_group' => 'auth_user_group', diff --git a/SL/DB/Manager/AuthMasterRight.pm b/SL/DB/Manager/AuthMasterRight.pm new file mode 100644 index 000000000..fe8606823 --- /dev/null +++ b/SL/DB/Manager/AuthMasterRight.pm @@ -0,0 +1,14 @@ +# This file has been auto-generated only because it didn't exist. +# Feel free to modify it at will; it will not be overwritten automatically. + +package SL::DB::Manager::AuthMasterRight; + +use strict; + +use parent qw(SL::DB::Helper::Manager); + +sub object_class { 'SL::DB::AuthMasterRight' } + +__PACKAGE__->make_manager_methods; + +1; diff --git a/SL/DB/Manager/AuthSchemaInfo.pm b/SL/DB/Manager/AuthSchemaInfo.pm new file mode 100644 index 000000000..3e72f851c --- /dev/null +++ b/SL/DB/Manager/AuthSchemaInfo.pm @@ -0,0 +1,14 @@ +# This file has been auto-generated only because it didn't exist. +# Feel free to modify it at will; it will not be overwritten automatically. + +package SL::DB::Manager::AuthSchemaInfo; + +use strict; + +use parent qw(SL::DB::Helper::Manager); + +sub object_class { 'SL::DB::AuthSchemaInfo' } + +__PACKAGE__->make_manager_methods; + +1; diff --git a/SL/DB/Manager/AuthSession.pm b/SL/DB/Manager/AuthSession.pm new file mode 100644 index 000000000..9289ad83d --- /dev/null +++ b/SL/DB/Manager/AuthSession.pm @@ -0,0 +1,14 @@ +# This file has been auto-generated only because it didn't exist. +# Feel free to modify it at will; it will not be overwritten automatically. + +package SL::DB::Manager::AuthSession; + +use strict; + +use parent qw(SL::DB::Helper::Manager); + +sub object_class { 'SL::DB::AuthSession' } + +__PACKAGE__->make_manager_methods; + +1; diff --git a/SL/DB/Manager/AuthSessionContent.pm b/SL/DB/Manager/AuthSessionContent.pm new file mode 100644 index 000000000..60c0a2d59 --- /dev/null +++ b/SL/DB/Manager/AuthSessionContent.pm @@ -0,0 +1,14 @@ +# This file has been auto-generated only because it didn't exist. +# Feel free to modify it at will; it will not be overwritten automatically. + +package SL::DB::Manager::AuthSessionContent; + +use strict; + +use parent qw(SL::DB::Helper::Manager); + +sub object_class { 'SL::DB::AuthSessionContent' } + +__PACKAGE__->make_manager_methods; + +1; diff --git a/SL/DB/MetaSetup/AuthClient.pm b/SL/DB/MetaSetup/AuthClient.pm index 8eb841cdd..5e9d59e04 100644 --- a/SL/DB/MetaSetup/AuthClient.pm +++ b/SL/DB/MetaSetup/AuthClient.pm @@ -4,20 +4,20 @@ package SL::DB::AuthClient; use strict; -use base qw(SL::DB::Object); +use parent qw(SL::DB::Object); __PACKAGE__->meta->table('clients'); __PACKAGE__->meta->schema('auth'); __PACKAGE__->meta->columns( - id => { type => 'serial', not_null => 1 }, - name => { type => 'text', not_null => 1 }, dbhost => { type => 'text', not_null => 1 }, - dbport => { type => 'integer', default => 5432, not_null => 1 }, dbname => { type => 'text', not_null => 1 }, - dbuser => { type => 'text', not_null => 1 }, dbpasswd => { type => 'text', not_null => 1 }, + dbport => { type => 'integer', default => 5432, not_null => 1 }, + dbuser => { type => 'text', not_null => 1 }, + id => { type => 'serial', not_null => 1 }, is_default => { type => 'boolean', default => 'false', not_null => 1 }, + name => { type => 'text', not_null => 1 }, ); __PACKAGE__->meta->primary_key_columns([ 'id' ]); @@ -27,7 +27,5 @@ __PACKAGE__->meta->unique_keys( [ 'name' ], ); -# __PACKAGE__->meta->initialize; - 1; ; diff --git a/SL/DB/MetaSetup/AuthClientGroup.pm b/SL/DB/MetaSetup/AuthClientGroup.pm index 9eac68415..d74a1ed2a 100644 --- a/SL/DB/MetaSetup/AuthClientGroup.pm +++ b/SL/DB/MetaSetup/AuthClientGroup.pm @@ -4,7 +4,7 @@ package SL::DB::AuthClientGroup; use strict; -use base qw(SL::DB::Object); +use parent qw(SL::DB::Object); __PACKAGE__->meta->table('clients_groups'); __PACKAGE__->meta->schema('auth'); @@ -28,7 +28,5 @@ __PACKAGE__->meta->foreign_keys( }, ); -# __PACKAGE__->meta->initialize; - 1; ; diff --git a/SL/DB/MetaSetup/AuthClientUser.pm b/SL/DB/MetaSetup/AuthClientUser.pm index 88a5177f1..6f8310594 100644 --- a/SL/DB/MetaSetup/AuthClientUser.pm +++ b/SL/DB/MetaSetup/AuthClientUser.pm @@ -4,7 +4,7 @@ package SL::DB::AuthClientUser; use strict; -use base qw(SL::DB::Object); +use parent qw(SL::DB::Object); __PACKAGE__->meta->table('clients_users'); __PACKAGE__->meta->schema('auth'); @@ -28,7 +28,5 @@ __PACKAGE__->meta->foreign_keys( }, ); -# __PACKAGE__->meta->initialize; - 1; ; diff --git a/SL/DB/MetaSetup/AuthGroup.pm b/SL/DB/MetaSetup/AuthGroup.pm index 2671cef8b..d1bc5fd88 100644 --- a/SL/DB/MetaSetup/AuthGroup.pm +++ b/SL/DB/MetaSetup/AuthGroup.pm @@ -4,22 +4,20 @@ package SL::DB::AuthGroup; use strict; -use base qw(SL::DB::Object); +use parent qw(SL::DB::Object); __PACKAGE__->meta->table('group'); __PACKAGE__->meta->schema('auth'); __PACKAGE__->meta->columns( + description => { type => 'text' }, id => { type => 'serial', not_null => 1 }, name => { type => 'text', not_null => 1 }, - description => { type => 'text' }, ); __PACKAGE__->meta->primary_key_columns([ 'id' ]); __PACKAGE__->meta->unique_keys([ 'name' ]); -# __PACKAGE__->meta->initialize; - 1; ; diff --git a/SL/DB/MetaSetup/AuthGroupRight.pm b/SL/DB/MetaSetup/AuthGroupRight.pm index 1befd3180..92c4db3e1 100644 --- a/SL/DB/MetaSetup/AuthGroupRight.pm +++ b/SL/DB/MetaSetup/AuthGroupRight.pm @@ -4,15 +4,15 @@ package SL::DB::AuthGroupRight; use strict; -use base qw(SL::DB::Object); +use parent qw(SL::DB::Object); __PACKAGE__->meta->table('group_rights'); __PACKAGE__->meta->schema('auth'); __PACKAGE__->meta->columns( + granted => { type => 'boolean', not_null => 1 }, group_id => { type => 'integer', not_null => 1 }, right => { type => 'text', not_null => 1 }, - granted => { type => 'boolean', not_null => 1 }, ); __PACKAGE__->meta->primary_key_columns([ 'group_id', 'right' ]); @@ -24,7 +24,5 @@ __PACKAGE__->meta->foreign_keys( }, ); -# __PACKAGE__->meta->initialize; - 1; ; diff --git a/SL/DB/MetaSetup/AuthMasterRight.pm b/SL/DB/MetaSetup/AuthMasterRight.pm new file mode 100644 index 000000000..8b231dca0 --- /dev/null +++ b/SL/DB/MetaSetup/AuthMasterRight.pm @@ -0,0 +1,25 @@ +# This file has been auto-generated. Do not modify it; it will be overwritten +# by rose_auto_create_model.pl automatically. +package SL::DB::AuthMasterRight; + +use strict; + +use parent qw(SL::DB::Object); + +__PACKAGE__->meta->table('master_rights'); +__PACKAGE__->meta->schema('auth'); + +__PACKAGE__->meta->columns( + category => { type => 'boolean', default => 'false', not_null => 1 }, + description => { type => 'text', not_null => 1 }, + id => { type => 'serial', not_null => 1 }, + name => { type => 'text', not_null => 1 }, + position => { type => 'integer', not_null => 1 }, +); + +__PACKAGE__->meta->primary_key_columns([ 'id' ]); + +__PACKAGE__->meta->unique_keys([ 'name' ]); + +1; +; diff --git a/SL/DB/MetaSetup/AuthSchemaInfo.pm b/SL/DB/MetaSetup/AuthSchemaInfo.pm new file mode 100644 index 000000000..20fdb5bcd --- /dev/null +++ b/SL/DB/MetaSetup/AuthSchemaInfo.pm @@ -0,0 +1,23 @@ +# This file has been auto-generated. Do not modify it; it will be overwritten +# by rose_auto_create_model.pl automatically. +package SL::DB::AuthSchemaInfo; + +use strict; + +use parent qw(SL::DB::Object); + +__PACKAGE__->meta->table('schema_info'); +__PACKAGE__->meta->schema('auth'); + +__PACKAGE__->meta->columns( + itime => { type => 'timestamp', default => 'now()' }, + login => { type => 'text' }, + tag => { type => 'text', not_null => 1 }, +); + +__PACKAGE__->meta->primary_key_columns([ 'tag' ]); + +__PACKAGE__->meta->allow_inline_column_values(1); + +1; +; diff --git a/SL/DB/MetaSetup/AuthSession.pm b/SL/DB/MetaSetup/AuthSession.pm new file mode 100644 index 000000000..84f0f677a --- /dev/null +++ b/SL/DB/MetaSetup/AuthSession.pm @@ -0,0 +1,22 @@ +# This file has been auto-generated. Do not modify it; it will be overwritten +# by rose_auto_create_model.pl automatically. +package SL::DB::AuthSession; + +use strict; + +use parent qw(SL::DB::Object); + +__PACKAGE__->meta->table('session'); +__PACKAGE__->meta->schema('auth'); + +__PACKAGE__->meta->columns( + api_token => { type => 'text' }, + id => { type => 'text', not_null => 1 }, + ip_address => { type => 'scalar' }, + mtime => { type => 'timestamp' }, +); + +__PACKAGE__->meta->primary_key_columns([ 'id' ]); + +1; +; diff --git a/SL/DB/MetaSetup/AuthSessionContent.pm b/SL/DB/MetaSetup/AuthSessionContent.pm new file mode 100644 index 000000000..4d08917c7 --- /dev/null +++ b/SL/DB/MetaSetup/AuthSessionContent.pm @@ -0,0 +1,22 @@ +# This file has been auto-generated. Do not modify it; it will be overwritten +# by rose_auto_create_model.pl automatically. +package SL::DB::AuthSessionContent; + +use strict; + +use parent qw(SL::DB::Object); + +__PACKAGE__->meta->table('session_content'); +__PACKAGE__->meta->schema('auth'); + +__PACKAGE__->meta->columns( + auto_restore => { type => 'boolean' }, + sess_key => { type => 'text', not_null => 1 }, + sess_value => { type => 'text' }, + session_id => { type => 'text', not_null => 1 }, +); + +__PACKAGE__->meta->primary_key_columns([ 'session_id', 'sess_key' ]); + +1; +; diff --git a/SL/DB/MetaSetup/AuthUser.pm b/SL/DB/MetaSetup/AuthUser.pm index 50b87ed11..ab05ab0b2 100644 --- a/SL/DB/MetaSetup/AuthUser.pm +++ b/SL/DB/MetaSetup/AuthUser.pm @@ -4,7 +4,7 @@ package SL::DB::AuthUser; use strict; -use base qw(SL::DB::Object); +use parent qw(SL::DB::Object); __PACKAGE__->meta->table('user'); __PACKAGE__->meta->schema('auth'); @@ -19,7 +19,5 @@ __PACKAGE__->meta->primary_key_columns([ 'id' ]); __PACKAGE__->meta->unique_keys([ 'login' ]); -# __PACKAGE__->meta->initialize; - 1; ; diff --git a/SL/DB/MetaSetup/AuthUserConfig.pm b/SL/DB/MetaSetup/AuthUserConfig.pm index 54ea6ce9d..8d065a027 100644 --- a/SL/DB/MetaSetup/AuthUserConfig.pm +++ b/SL/DB/MetaSetup/AuthUserConfig.pm @@ -4,15 +4,15 @@ package SL::DB::AuthUserConfig; use strict; -use base qw(SL::DB::Object); +use parent qw(SL::DB::Object); __PACKAGE__->meta->table('user_config'); __PACKAGE__->meta->schema('auth'); __PACKAGE__->meta->columns( - user_id => { type => 'integer', not_null => 1 }, cfg_key => { type => 'text', not_null => 1 }, cfg_value => { type => 'text' }, + user_id => { type => 'integer', not_null => 1 }, ); __PACKAGE__->meta->primary_key_columns([ 'user_id', 'cfg_key' ]); @@ -24,7 +24,5 @@ __PACKAGE__->meta->foreign_keys( }, ); -# __PACKAGE__->meta->initialize; - 1; ; diff --git a/SL/DB/MetaSetup/AuthUserGroup.pm b/SL/DB/MetaSetup/AuthUserGroup.pm index 6b470cf6c..321e6c791 100644 --- a/SL/DB/MetaSetup/AuthUserGroup.pm +++ b/SL/DB/MetaSetup/AuthUserGroup.pm @@ -4,14 +4,14 @@ package SL::DB::AuthUserGroup; use strict; -use base qw(SL::DB::Object); +use parent qw(SL::DB::Object); __PACKAGE__->meta->table('user_group'); __PACKAGE__->meta->schema('auth'); __PACKAGE__->meta->columns( - user_id => { type => 'integer', not_null => 1 }, group_id => { type => 'integer', not_null => 1 }, + user_id => { type => 'integer', not_null => 1 }, ); __PACKAGE__->meta->primary_key_columns([ 'user_id', 'group_id' ]); @@ -28,7 +28,5 @@ __PACKAGE__->meta->foreign_keys( }, ); -# __PACKAGE__->meta->initialize; - 1; ; diff --git a/scripts/rose_auto_create_model.pl b/scripts/rose_auto_create_model.pl index 54693cb76..d58a84602 100755 --- a/scripts/rose_auto_create_model.pl +++ b/scripts/rose_auto_create_model.pl @@ -13,7 +13,7 @@ use Data::Dumper; use Digest::MD5 qw(md5_hex); use English qw( -no_match_vars ); use Getopt::Long; -use List::MoreUtils qw(none); +use List::MoreUtils qw(apply none uniq); use List::UtilsBy qw(partition_by); use Pod::Usage; use Rose::DB::Object 0.809; @@ -340,6 +340,22 @@ sub usage { pod2usage(verbose => 99, sections => 'SYNOPSIS'); } +sub list_all_tables { + my ($db) = @_; + + my @schemas = (undef, uniq apply { s{\..*}{} } grep { m{\.} } keys %{ $package_names{KIVITENDO} }); + my @tables; + + foreach my $schema (@schemas) { + $db->schema($schema); + push @tables, map { $schema ? "${schema}.${_}" : $_ } $db->list_tables; + } + + $db->schema(undef); + + return @tables; +} + sub make_tables { my %tables_by_domain; if ($config{all}) { @@ -347,7 +363,7 @@ sub make_tables { foreach my $domain (@domains) { my $db = SL::DB::create(undef, $domain); - $tables_by_domain{$domain} = [ grep { my $table = $_; none { $_ eq $table } @{ $blacklist{$domain} } } $db->list_tables ]; + $tables_by_domain{$domain} = [ grep { my $table = $_; none { $_ eq $table } @{ $blacklist{$domain} } } list_all_tables($db) ]; $db->disconnect; } diff --git a/sql/Pg-upgrade2-auth/session_content_primary_key.sql b/sql/Pg-upgrade2-auth/session_content_primary_key.sql new file mode 100644 index 000000000..0cf80179c --- /dev/null +++ b/sql/Pg-upgrade2-auth/session_content_primary_key.sql @@ -0,0 +1,4 @@ +-- @tag: session_content_primary_key +-- @description: Primärschlüssel für Tabelle auth.session_content +-- @depends: release_3_3_0 +ALTER TABLE auth.session_content ADD PRIMARY KEY (session_id, sess_key); -- 2.20.1