diff --git a/Sam/Calendar.pm b/Sam/Calendar.pm new file mode 100644 index 0000000000000000000000000000000000000000..e48815ad03bce777029357b7e019f4bd0ec8521c --- /dev/null +++ b/Sam/Calendar.pm @@ -0,0 +1,25 @@ +package Sam::Calendar; + +use base qw(Sam::DB::Object); + +__PACKAGE__->meta->setup +( + table => 'sam_calendars', + auto => 1, +); + +__PACKAGE__->meta->setup +( + table => 'sam_calendars', + + columns => + [ + id => { type => 'integer', not_null => 1 }, + open => { type => 'boolean', not_null => 1, default => 0}, + name => { type => 'varchar', length => 20, not_null => 1 }, + ], + + primary_key_columns => [ 'id' ], +); + +1; diff --git a/Sam/Chan.pm b/Sam/Chan.pm new file mode 100644 index 0000000000000000000000000000000000000000..268a2aa7f7708e8481d13f83ae238a511040b6b8 --- /dev/null +++ b/Sam/Chan.pm @@ -0,0 +1,27 @@ +package Sam::Chan; + +use base qw(Sam::DB::Object); + +__PACKAGE__->meta->setup +( + table => 'sam_channels', + + columns => + [ + calendar_id => { type => 'integer', not_null => 1 }, + name => { type => 'varchar', length => 20, not_null => 1 }, + ], + + primary_key_columns => [ 'name' ], + + foreign_keys => + [ + calendar => + { + class => 'Sam::Calendar', + key_columns => { calendar_id => 'id' }, + }, + ], +); + +1; diff --git a/Sam/DB.pm.sample b/Sam/DB.pm.sample new file mode 100644 index 0000000000000000000000000000000000000000..6804ed20415dd3ec876eb67707ede3f31a469382 --- /dev/null +++ b/Sam/DB.pm.sample @@ -0,0 +1,13 @@ +package Sam::DB; + +use base qw(Rose::DB); + +__PACKAGE__->use_private_registry; + +__PACKAGE__->register_db( + driver => 'mysql', + database => '', + host => '', + username => '', + password => '', +); diff --git a/Sam/DB/Object.pm b/Sam/DB/Object.pm new file mode 100644 index 0000000000000000000000000000000000000000..f12def17162a084a3f76e0511859aceb550c0e00 --- /dev/null +++ b/Sam/DB/Object.pm @@ -0,0 +1,8 @@ +package Sam::DB::Object; + +use Sam::DB; +use base qw(Rose::DB::Object); + +sub init_db { Sam::DB->new } + +1; diff --git a/Sam/Event.pm b/Sam/Event.pm new file mode 100644 index 0000000000000000000000000000000000000000..3df90896b0fa3fe75490668d69b918e3e79d9134 --- /dev/null +++ b/Sam/Event.pm @@ -0,0 +1,32 @@ +package Sam::Event; + +use base qw(Sam::DB::Object); + +__PACKAGE__->meta->setup +( + table => 'sam', + + columns => + [ + id => { type => 'integer', not_null => 1 }, + title => { type => 'varchar', length => 255, not_null => 1 }, + date => { type => 'timestamp', not_null => 1 }, + place => { type => 'varchar', length => 255 }, + description => { type => 'varchar', length => 500 }, + link => { type => 'varchar', length => 1000 }, + calendar_id => { type => 'integer', not_null => 1 }, + ], + + primary_key_columns => [ 'id' ], + + foreign_keys => + [ + calendar => + { + class => 'Sam::Calendar', + key_columns => { calendar_id => 'id' }, + }, + ], +); + +1;