--- /dev/null
+package CookBook::Db::Properties;
+
+# $Id$
+# $URL$
+
+=head1 NAME
+
+CookBook::Db::Properties
+
+=head1 DESCRIPTION
+
+Module for abstract database access to the table 'properties'
+
+=cut
+
+#---------------------------------------------------------------------------
+
+use strict;
+use warnings;
+
+use CookBook::Common;
+use base qw/DBIx::Class/;
+
+__PACKAGE__->load_components(
+ qw/
+ PK::Auto
+ Core
+ /
+);
+
+__PACKAGE__->table('properties');
+
+__PACKAGE__->add_columns(
+ "property_id" => {
+ 'data_type' => "INT",
+ 'default_value' => undef,
+ 'is_nullable' => 0,
+ 'size' => 10,
+ 'is_auto_increment' => 1,
+ 'extras' => { 'unsigned' => 1 },
+ },
+ "property_name" => { 'data_type' => "VARCHAR", 'default_value' => "", 'is_nullable' => 0, 'size' => 100 },
+ "units" => { 'data_type' => "VARCHAR", 'default_value' => undef, 'is_nullable' => 1, 'size' => 30 },
+ "date_created" => { 'data_type' => "DATETIME", 'default_value' => "", 'is_nullable' => 0, 'size' => 19 },
+ "date_changed" => { 'data_type' => "DATETIME", 'default_value' => "", 'is_nullable' => 0, 'size' => 19 },
+);
+
+__PACKAGE__->set_primary_key("property_id");
+__PACKAGE__->add_unique_constraint( "property_name", ["property_name"] );
+
+#----------------------------------------------------------------------------------------
+
+1;
+
+#----------------------------------------------------------------------------------------
+
+__END__
+
yield_types
unit_types
units
+ properties
categories
ingredients
ingredient_groups
'units' => \&create_units_table,
'categories' => \&create_categories_table,
'recipe_categories' => \&create_recipe_categories_table,
+ 'properties' => \&create_properties_table,
);
my @import_tables = qw(
yield_types
units
categories
+ properties
ingredients
ingredient_groups
recipes
'recipes' => \&import_recipes_table,
'recipe_authors' => \&import_recipe_authors_table,
'recipe_ingredients' => \&import_recipe_ingredients_table,
+ 'properties' => \&import_properties_table,
);
my $admin_data = {
#-------------------------------------------------------------
+=head2 create_properties_table( )
+
+=cut
+
+sub create_properties_table {
+
+ my $sql = <<END_SQL;
+CREATE TABLE `properties` (
+ `property_id` int(10) unsigned NOT NULL auto_increment,
+ `property_name` varchar(100) NOT NULL COMMENT 'Name der Eigenschaft',
+ `units` varchar(30) COMMENT 'Maßeinheit für diese Eigenschaft',
+ `date_created` datetime NOT NULL,
+ `date_changed` datetime NOT NULL,
+ PRIMARY KEY (`property_id`),
+ UNIQUE KEY `property_name` (`property_name`)
+) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT='Eigenschaften für Zutaten'
+END_SQL
+
+ return undef unless $target_dbh->do($sql);
+ return 1;
+
+} ## end sub create_recipe_authors_table
+
+#-------------------------------------------------------------
+
+=head2 import_categories_table( )
+
+=cut
+
+sub import_properties_table {
+
+ my $sql = <<END_SQL;
+SELECT `id`, `name`, `units`
+ FROM `ingredient_properties`
+ ORDER BY `name`
+END_SQL
+
+ my ( $source_sth, $target_sth, $prop, $qparams );
+
+ unless ( $source_sth = $source_dbh->prepare($sql) ) {
+ return undef;
+ }
+
+ return undef unless $source_sth->execute();
+
+ $sql = <<END_SQL;
+INSERT INTO `properties` ( `property_id`, `property_name`, `units`, `date_created`, `date_changed` )
+ VALUES ( ?, ?, ?, now(), now() )
+END_SQL
+ $target_sth = $target_dbh->prepare($sql);
+ unless ($target_sth) {
+ $source_sth->finish();
+ return undef;
+ }
+
+ while ( $prop = $source_sth->fetchrow_hashref() ) {
+
+ next unless $prop->{'name'};
+
+ $qparams = [];
+ push @$qparams, $prop->{'id'};
+ push @$qparams, $prop->{'name'};
+ push @$qparams, $prop->{'units'};
+
+ unless ( $target_dbh->do( $sql, {}, @$qparams ) ) {
+ $source_sth->finish();
+ return undef;
+ }
+
+ } ## end while ( $ingr = $source_sth->fetchrow_hashref...
+
+ return 1;
+
+} ## end sub import_ingredients_table
+
+#-------------------------------------------------------------
+
=head2 create_session_table( )
=cut