From: Frank Brehm Date: Fri, 16 Jul 2010 11:48:37 +0000 (+0000) Subject: Mit Datenbank-Schema anfgefangen X-Git-Url: https://git.uhu-banane.de/?a=commitdiff_plain;h=483a8f5619c47504dc2af47625eddb1e0c9b6ccd;p=my-stuff%2Fpostfix-maps.git Mit Datenbank-Schema anfgefangen git-svn-id: http://svn.brehm-online.com/svn/my-stuff/postfix-maps/trunk@100 ec8d2aa5-1599-4edb-8739-2b3a1bc399aa --- diff --git a/etc/config.yml b/etc/config.yml index a7b3a12..b58bbc7 100644 --- a/etc/config.yml +++ b/etc/config.yml @@ -13,3 +13,11 @@ # # Das globale Verzeichnis der Postfix-Konfiguration #postfixdir: '/etc/postfix' +# +# Datenbank-Konfiguration +#schema_class: 'FrBr::Postffix::Db' +'Model::Schema': + connect_info: + dsn: 'DBI:mysql:database=vmail;host=localhost' + user: 'vmail' + password: ~ diff --git a/lib/FrBr/Postfix/App.pm b/lib/FrBr/Postfix/App.pm index b7ecee1..7a9dc4b 100644 --- a/lib/FrBr/Postfix/App.pm +++ b/lib/FrBr/Postfix/App.pm @@ -74,6 +74,44 @@ sub _build_postfixdir { return dir->new( '/etc/postfix' ); } +#--------------------------------------------------------------------------- + +# Ändern der Eigenschaften einiger geerbter Attribute + +############################################################################################# + +=head1 Überschriebene Build-Methoden + +=cut + +#------ + +=head2 _build_default_config( ) + +=cut + +sub _build_default_config { + return { + postfix_dir => '/etc/postfix', + 'Model::Schema' => { + 'schema_class' => 'FrBr::Postfix::Db', + 'connect_info' => { + 'dsn' => 'DBI:mysql:database=vmail;host=localhost', + 'user' => 'vmail', + 'password' => undef, + 'AutoCommit' => 1, + 'PrintError' => 0, + 'RaiseError' => 0, + 'quote_char' => '`', + 'name_sep' => '.', + 'on_connect_do' => [ + "SET NAMES 'utf8'", + ], + }, + }, + }; +} + ########################################################################### =head1 METHODS @@ -137,6 +175,10 @@ after 'evaluate_config' => sub { } } + if ( $key =~ /^schema[-_]?class$/i and not $self->config->{'schema_class'} ) { + $self->config->{'schema_class'} = $val; + } + } unless ( $self->postfix_dir->is_absolute ) { @@ -168,6 +210,8 @@ after 'init_app' => sub { } + $self->init_db_schema(); + }; #--------------------------------- diff --git a/lib/FrBr/Postfix/Db.pm b/lib/FrBr/Postfix/Db.pm new file mode 100644 index 0000000..2b16050 --- /dev/null +++ b/lib/FrBr/Postfix/Db.pm @@ -0,0 +1,18 @@ +package FrBr::Postfix::Db; + +# $Id$ +# $URL$ + +use strict; +use warnings; + +use base 'DBIx::Class::Schema'; + +__PACKAGE__->load_namespaces; +#__PACKAGE__->load_classes; + +1; + +__END__ + +# vim: noai : ts=4 fenc=utf-8 filetype=perl expandtab : diff --git a/lib/FrBr/Postfix/Db/Result/Alias.pm b/lib/FrBr/Postfix/Db/Result/Alias.pm new file mode 100644 index 0000000..be08a89 --- /dev/null +++ b/lib/FrBr/Postfix/Db/Result/Alias.pm @@ -0,0 +1,27 @@ +package FrBr::Postfix::Db::Result::Alias; + +# $Id$ +# $URL$ + +use strict; +use warnings; + +use base 'DBIx::Class'; + +__PACKAGE__->load_components("Core"); +__PACKAGE__->table("alias"); +__PACKAGE__->add_columns( + "id" => { data_type => "INT", default_value => undef, is_nullable => 0, size => 10 }, + "alias" => { data_type => "VARCHAR", default_value => undef, is_nullable => 0, size => 128, }, + "destination" => { data_type => "VARCHAR", default_value => undef, is_nullable => 0, size => 128, }, + "enabled" => { data_type => "ENUM", default_value => 'y', is_nullable => 0, size => 1, }, + "changed_at" => { data_type => "TIMESTAMP", default_value => undef, is_nullable => 0, size => 19, }, +); + +__PACKAGE__->set_primary_key("id"); + +1; + +__END__ + +# vim: noai : ts=4 fenc=utf-8 filetype=perl expandtab :