]> Frank Brehm's Git Trees - my-stuff/postfix-maps.git/commitdiff
Mit Datenbank-Schema anfgefangen
authorFrank Brehm <frank@brehm-online.com>
Fri, 16 Jul 2010 11:48:37 +0000 (11:48 +0000)
committerFrank Brehm <frank@brehm-online.com>
Fri, 16 Jul 2010 11:48:37 +0000 (11:48 +0000)
git-svn-id: http://svn.brehm-online.com/svn/my-stuff/postfix-maps/trunk@100 ec8d2aa5-1599-4edb-8739-2b3a1bc399aa

etc/config.yml
lib/FrBr/Postfix/App.pm
lib/FrBr/Postfix/Db.pm [new file with mode: 0644]
lib/FrBr/Postfix/Db/Result/Alias.pm [new file with mode: 0644]

index a7b3a12a749081f874e626deff41dce0525bf76e..b58bbc7a324df5dbc77bfb30eeea69c9d30730d5 100644 (file)
 #
 # 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: ~
index b7ecee17a93334d29325e16bdfb081d86e59442a..7a9dc4b1701a877d28548080067a53161ebd58d5 100644 (file)
@@ -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 (file)
index 0000000..2b16050
--- /dev/null
@@ -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 (file)
index 0000000..be08a89
--- /dev/null
@@ -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 :