package User; use strict; use base qw(DB::Object); __PACKAGE__->meta->setup ( table => 'users', columns => [ id => { type => 'integer', not_null => 1 }, name => { type => 'varchar', length => 32, not_null => 1 }, password => { type => 'varchar', length => 40, not_null => 1 }, password_forcechange => { type => 'enum', check_in => [ 'Y', 'N' ], not_null => 1 }, last_ip => { type => 'varchar', length => 15 }, last_login => { type => 'timestamp' }, ], primary_key_columns => [ 'id' ], unique_key => [ 'name' ], foreign_keys => [ ], relationships => [ contact => { type => 'one to one', class => 'User::Contact', column_map => { id => 'user_id' }, }, ] ); 1; package User::Contact; use strict; use base qw(DB::Object); __PACKAGE__->meta->setup ( table => 'users_contact', columns => [ user_id => { type => 'integer', not_null => 1 }, email => { type => 'varchar', length => 128 }, homepage => { type => 'varchar', length => 256 }, phone => { type => 'text', length => 65535 }, messenger => { type => 'text', length => 65535 }, ], primary_key_columns => [ 'user_id' ], relationships => [ user => { type => 'one to one', class => 'User', column_map => { 'user_id' => 'id' }, }, ], ); 1;