Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Changed DDL, added dbic.conf and generated DBIC classes.
- Loading branch information
Showing
6 changed files
with
391 additions
and
7 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,18 @@ | ||
schema_class TwittElection::Schema | ||
|
||
lib lib | ||
|
||
# connection string | ||
<connect_info> | ||
dsn dbi:mysql:database=twittelection | ||
user root | ||
pass | ||
</connect_info> | ||
|
||
# dbic loader options | ||
<loader_options> | ||
dump_directory ./lib | ||
components InflateColumn::DateTime | ||
components TimeStamp | ||
use_moose 1 | ||
</loader_options> |
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
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,20 @@ | ||
use utf8; | ||
package TwittElection::Schema; | ||
|
||
# Created by DBIx::Class::Schema::Loader | ||
# DO NOT MODIFY THE FIRST PART OF THIS FILE | ||
|
||
use Moose; | ||
use MooseX::MarkAsMethods autoclean => 1; | ||
extends 'DBIx::Class::Schema'; | ||
|
||
__PACKAGE__->load_namespaces; | ||
|
||
|
||
# Created by DBIx::Class::Schema::Loader v0.07039 @ 2014-08-15 20:12:34 | ||
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:POtcyUDJVg5/NGxsfXb2fQ | ||
|
||
|
||
# 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,151 @@ | ||
use utf8; | ||
package TwittElection::Schema::Result::Candidate; | ||
|
||
# Created by DBIx::Class::Schema::Loader | ||
# DO NOT MODIFY THE FIRST PART OF THIS FILE | ||
|
||
=head1 NAME | ||
TwittElection::Schema::Result::Candidate | ||
=cut | ||
|
||
use strict; | ||
use warnings; | ||
|
||
use Moose; | ||
use MooseX::NonMoose; | ||
use MooseX::MarkAsMethods autoclean => 1; | ||
extends 'DBIx::Class::Core'; | ||
|
||
=head1 COMPONENTS LOADED | ||
=over 4 | ||
=item * L<DBIx::Class::InflateColumn::DateTime> | ||
=item * L<DBIx::Class::TimeStamp> | ||
=back | ||
=cut | ||
|
||
__PACKAGE__->load_components("InflateColumn::DateTime", "TimeStamp"); | ||
|
||
=head1 TABLE: C<candidate> | ||
=cut | ||
|
||
__PACKAGE__->table("candidate"); | ||
|
||
=head1 ACCESSORS | ||
=head2 id | ||
data_type: 'integer' | ||
is_nullable: 0 | ||
=head2 name | ||
data_type: 'varchar' | ||
is_nullable: 0 | ||
size: 200 | ||
=head2 twitter | ||
data_type: 'varchar' | ||
is_nullable: 1 | ||
size: 200 | ||
=head2 party_id | ||
data_type: 'integer' | ||
is_foreign_key: 1 | ||
is_nullable: 0 | ||
=head2 constituency_id | ||
data_type: 'integer' | ||
is_foreign_key: 1 | ||
is_nullable: 1 | ||
=head2 current_mp | ||
data_type: 'integer' | ||
default_value: 0 | ||
is_nullable: 0 | ||
=cut | ||
|
||
__PACKAGE__->add_columns( | ||
"id", | ||
{ data_type => "integer", is_nullable => 0 }, | ||
"name", | ||
{ data_type => "varchar", is_nullable => 0, size => 200 }, | ||
"twitter", | ||
{ data_type => "varchar", is_nullable => 1, size => 200 }, | ||
"party_id", | ||
{ data_type => "integer", is_foreign_key => 1, is_nullable => 0 }, | ||
"constituency_id", | ||
{ data_type => "integer", is_foreign_key => 1, is_nullable => 1 }, | ||
"current_mp", | ||
{ data_type => "integer", default_value => 0, is_nullable => 0 }, | ||
); | ||
|
||
=head1 PRIMARY KEY | ||
=over 4 | ||
=item * L</id> | ||
=back | ||
=cut | ||
|
||
__PACKAGE__->set_primary_key("id"); | ||
|
||
=head1 RELATIONS | ||
=head2 constituency | ||
Type: belongs_to | ||
Related object: L<TwittElection::Schema::Result::Constituency> | ||
=cut | ||
|
||
__PACKAGE__->belongs_to( | ||
"constituency", | ||
"TwittElection::Schema::Result::Constituency", | ||
{ id => "constituency_id" }, | ||
{ | ||
is_deferrable => 1, | ||
join_type => "LEFT", | ||
on_delete => "RESTRICT", | ||
on_update => "RESTRICT", | ||
}, | ||
); | ||
|
||
=head2 party | ||
Type: belongs_to | ||
Related object: L<TwittElection::Schema::Result::Party> | ||
=cut | ||
|
||
__PACKAGE__->belongs_to( | ||
"party", | ||
"TwittElection::Schema::Result::Party", | ||
{ id => "party_id" }, | ||
{ is_deferrable => 1, on_delete => "RESTRICT", on_update => "RESTRICT" }, | ||
); | ||
|
||
|
||
# Created by DBIx::Class::Schema::Loader v0.07039 @ 2014-08-15 20:12:34 | ||
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:CpWHo/zzZ6BBuVPuTXoQAQ | ||
|
||
|
||
# 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,99 @@ | ||
use utf8; | ||
package TwittElection::Schema::Result::Constituency; | ||
|
||
# Created by DBIx::Class::Schema::Loader | ||
# DO NOT MODIFY THE FIRST PART OF THIS FILE | ||
|
||
=head1 NAME | ||
TwittElection::Schema::Result::Constituency | ||
=cut | ||
|
||
use strict; | ||
use warnings; | ||
|
||
use Moose; | ||
use MooseX::NonMoose; | ||
use MooseX::MarkAsMethods autoclean => 1; | ||
extends 'DBIx::Class::Core'; | ||
|
||
=head1 COMPONENTS LOADED | ||
=over 4 | ||
=item * L<DBIx::Class::InflateColumn::DateTime> | ||
=item * L<DBIx::Class::TimeStamp> | ||
=back | ||
=cut | ||
|
||
__PACKAGE__->load_components("InflateColumn::DateTime", "TimeStamp"); | ||
|
||
=head1 TABLE: C<constituency> | ||
=cut | ||
|
||
__PACKAGE__->table("constituency"); | ||
|
||
=head1 ACCESSORS | ||
=head2 id | ||
data_type: 'integer' | ||
is_nullable: 0 | ||
=head2 name | ||
data_type: 'varchar' | ||
is_nullable: 0 | ||
size: 200 | ||
=cut | ||
|
||
__PACKAGE__->add_columns( | ||
"id", | ||
{ data_type => "integer", is_nullable => 0 }, | ||
"name", | ||
{ data_type => "varchar", is_nullable => 0, size => 200 }, | ||
); | ||
|
||
=head1 PRIMARY KEY | ||
=over 4 | ||
=item * L</id> | ||
=back | ||
=cut | ||
|
||
__PACKAGE__->set_primary_key("id"); | ||
|
||
=head1 RELATIONS | ||
=head2 candidates | ||
Type: has_many | ||
Related object: L<TwittElection::Schema::Result::Candidate> | ||
=cut | ||
|
||
__PACKAGE__->has_many( | ||
"candidates", | ||
"TwittElection::Schema::Result::Candidate", | ||
{ "foreign.constituency_id" => "self.id" }, | ||
{ cascade_copy => 0, cascade_delete => 0 }, | ||
); | ||
|
||
|
||
# Created by DBIx::Class::Schema::Loader v0.07039 @ 2014-08-15 20:12:34 | ||
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:3nXUzbwFvl5i0kTFMaVjNQ | ||
|
||
|
||
# You can replace this text with custom code or comments, and it will be preserved on regeneration | ||
__PACKAGE__->meta->make_immutable; | ||
1; |
Oops, something went wrong.