Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
DBIC Schema and DB models
- Loading branch information
1 parent
1ae6c21
commit b782e1e
Showing
6 changed files
with
326 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package Catalyst::Default::Model::DB; | ||
|
||
use strict; | ||
use base 'Catalyst::Model::DBIC::Schema'; | ||
|
||
__PACKAGE__->config( | ||
schema_class => 'Catalyst::Default::Schema', | ||
|
||
connect_info => { | ||
dsn => 'dbi:Pg:dbname=default-catalyst', | ||
user => 'catalyst', | ||
password => 'catalyst', | ||
AutoCommit => q{1}, | ||
} | ||
); | ||
|
||
=head1 NAME | ||
Catalyst::Default::Model::DB - Catalyst DBIC Schema Model | ||
=head1 SYNOPSIS | ||
See L<Catalyst::Default> | ||
=head1 DESCRIPTION | ||
L<Catalyst::Model::DBIC::Schema> Model using schema L<Catalyst::Default::Schema> | ||
=head1 GENERATED BY | ||
Catalyst::Helper::Model::DBIC::Schema - 0.54 | ||
=head1 AUTHOR | ||
Phillip Smith | ||
=head1 LICENSE | ||
This library is free software, you can redistribute it and/or modify | ||
it under the same terms as Perl itself. | ||
=cut | ||
|
||
1; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package Catalyst::Default::Schema; | ||
|
||
# Created by DBIx::Class::Schema::Loader | ||
# DO NOT MODIFY THE FIRST PART OF THIS FILE | ||
|
||
use Moose; | ||
use namespace::autoclean; | ||
extends 'DBIx::Class::Schema'; | ||
|
||
__PACKAGE__->load_namespaces; | ||
|
||
|
||
# Created by DBIx::Class::Schema::Loader v0.07010 @ 2011-08-15 16:57:36 | ||
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:d9ICGUTp7SSsHfAeWHva3A | ||
|
||
|
||
# You can replace this text with custom code or comments, and it will be preserved on regeneration | ||
__PACKAGE__->meta->make_immutable(inline_constructor => 0); | ||
1; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
package Catalyst::Default::Schema::Result::Author; | ||
|
||
# Created by DBIx::Class::Schema::Loader | ||
# DO NOT MODIFY THE FIRST PART OF THIS FILE | ||
|
||
use strict; | ||
use warnings; | ||
|
||
use Moose; | ||
use MooseX::NonMoose; | ||
use namespace::autoclean; | ||
extends 'DBIx::Class::Core'; | ||
|
||
__PACKAGE__->load_components("InflateColumn::DateTime"); | ||
|
||
=head1 NAME | ||
Catalyst::Default::Schema::Result::Author | ||
=cut | ||
|
||
__PACKAGE__->table("authors"); | ||
|
||
=head1 ACCESSORS | ||
=head2 id | ||
data_type: 'integer' | ||
is_auto_increment: 1 | ||
is_nullable: 0 | ||
sequence: 'authors_id_seq' | ||
=head2 first_name | ||
data_type: 'text' | ||
is_nullable: 1 | ||
=head2 last_name | ||
data_type: 'text' | ||
is_nullable: 1 | ||
=cut | ||
|
||
__PACKAGE__->add_columns( | ||
"id", | ||
{ | ||
data_type => "integer", | ||
is_auto_increment => 1, | ||
is_nullable => 0, | ||
sequence => "authors_id_seq", | ||
}, | ||
"first_name", | ||
{ data_type => "text", is_nullable => 1 }, | ||
"last_name", | ||
{ data_type => "text", is_nullable => 1 }, | ||
); | ||
__PACKAGE__->set_primary_key("id"); | ||
|
||
=head1 RELATIONS | ||
=head2 book_authors | ||
Type: has_many | ||
Related object: L<Catalyst::Default::Schema::Result::BookAuthor> | ||
=cut | ||
|
||
__PACKAGE__->has_many( | ||
"book_authors", | ||
"Catalyst::Default::Schema::Result::BookAuthor", | ||
{ "foreign.author_id" => "self.id" }, | ||
{ cascade_copy => 0, cascade_delete => 0 }, | ||
); | ||
|
||
|
||
# Created by DBIx::Class::Schema::Loader v0.07010 @ 2011-08-15 16:57:36 | ||
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:sEll7GyxyTyrWr9lAANYXw | ||
|
||
|
||
# You can replace this text with custom code or comments, and it will be preserved on regeneration | ||
__PACKAGE__->meta->make_immutable; | ||
1; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
package Catalyst::Default::Schema::Result::Book; | ||
|
||
# Created by DBIx::Class::Schema::Loader | ||
# DO NOT MODIFY THE FIRST PART OF THIS FILE | ||
|
||
use strict; | ||
use warnings; | ||
|
||
use Moose; | ||
use MooseX::NonMoose; | ||
use namespace::autoclean; | ||
extends 'DBIx::Class::Core'; | ||
|
||
__PACKAGE__->load_components("InflateColumn::DateTime"); | ||
|
||
=head1 NAME | ||
Catalyst::Default::Schema::Result::Book | ||
=cut | ||
|
||
__PACKAGE__->table("books"); | ||
|
||
=head1 ACCESSORS | ||
=head2 id | ||
data_type: 'integer' | ||
is_auto_increment: 1 | ||
is_nullable: 0 | ||
sequence: 'books_id_seq' | ||
=head2 title | ||
data_type: 'text' | ||
is_nullable: 1 | ||
=head2 rating | ||
data_type: 'integer' | ||
is_nullable: 1 | ||
=cut | ||
|
||
__PACKAGE__->add_columns( | ||
"id", | ||
{ | ||
data_type => "integer", | ||
is_auto_increment => 1, | ||
is_nullable => 0, | ||
sequence => "books_id_seq", | ||
}, | ||
"title", | ||
{ data_type => "text", is_nullable => 1 }, | ||
"rating", | ||
{ data_type => "integer", is_nullable => 1 }, | ||
); | ||
__PACKAGE__->set_primary_key("id"); | ||
|
||
=head1 RELATIONS | ||
=head2 book_authors | ||
Type: has_many | ||
Related object: L<Catalyst::Default::Schema::Result::BookAuthor> | ||
=cut | ||
|
||
__PACKAGE__->has_many( | ||
"book_authors", | ||
"Catalyst::Default::Schema::Result::BookAuthor", | ||
{ "foreign.book_id" => "self.id" }, | ||
{ cascade_copy => 0, cascade_delete => 0 }, | ||
); | ||
|
||
|
||
# Created by DBIx::Class::Schema::Loader v0.07010 @ 2011-08-15 16:57:36 | ||
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:bqZ1qYHTaa2IJCjHRZjnoA | ||
|
||
|
||
# You can replace this text with custom code or comments, and it will be preserved on regeneration | ||
__PACKAGE__->meta->make_immutable; | ||
1; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
package Catalyst::Default::Schema::Result::BookAuthor; | ||
|
||
# Created by DBIx::Class::Schema::Loader | ||
# DO NOT MODIFY THE FIRST PART OF THIS FILE | ||
|
||
use strict; | ||
use warnings; | ||
|
||
use Moose; | ||
use MooseX::NonMoose; | ||
use namespace::autoclean; | ||
extends 'DBIx::Class::Core'; | ||
|
||
__PACKAGE__->load_components("InflateColumn::DateTime"); | ||
|
||
=head1 NAME | ||
Catalyst::Default::Schema::Result::BookAuthor | ||
=cut | ||
|
||
__PACKAGE__->table("book_authors"); | ||
|
||
=head1 ACCESSORS | ||
=head2 book_id | ||
data_type: 'integer' | ||
is_foreign_key: 1 | ||
is_nullable: 0 | ||
=head2 author_id | ||
data_type: 'integer' | ||
is_foreign_key: 1 | ||
is_nullable: 0 | ||
=cut | ||
|
||
__PACKAGE__->add_columns( | ||
"book_id", | ||
{ data_type => "integer", is_foreign_key => 1, is_nullable => 0 }, | ||
"author_id", | ||
{ data_type => "integer", is_foreign_key => 1, is_nullable => 0 }, | ||
); | ||
__PACKAGE__->set_primary_key("book_id", "author_id"); | ||
|
||
=head1 RELATIONS | ||
=head2 author | ||
Type: belongs_to | ||
Related object: L<Catalyst::Default::Schema::Result::Author> | ||
=cut | ||
|
||
__PACKAGE__->belongs_to( | ||
"author", | ||
"Catalyst::Default::Schema::Result::Author", | ||
{ id => "author_id" }, | ||
{ is_deferrable => 1, on_delete => "CASCADE", on_update => "CASCADE" }, | ||
); | ||
|
||
=head2 book | ||
Type: belongs_to | ||
Related object: L<Catalyst::Default::Schema::Result::Book> | ||
=cut | ||
|
||
__PACKAGE__->belongs_to( | ||
"book", | ||
"Catalyst::Default::Schema::Result::Book", | ||
{ id => "book_id" }, | ||
{ is_deferrable => 1, on_delete => "CASCADE", on_update => "CASCADE" }, | ||
); | ||
|
||
|
||
# Created by DBIx::Class::Schema::Loader v0.07010 @ 2011-08-15 16:57:36 | ||
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:6Mpl+gFIwutn9r18pyEX1A | ||
|
||
|
||
# You can replace this text with custom code or comments, and it will be preserved on regeneration | ||
__PACKAGE__->meta->make_immutable; | ||
1; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
use strict; | ||
use warnings; | ||
use Test::More; | ||
use Test::More; | ||
|
||
BEGIN { use_ok 'Catalyst::Default::Model::DB' } | ||
|
||
done_testing(); |