diff options
author | Matthew Somerville <matthew@mysociety.org> | 2012-12-19 14:19:30 +0000 |
---|---|---|
committer | Matthew Somerville <matthew@mysociety.org> | 2012-12-19 14:43:26 +0000 |
commit | 1c1e454cc049531fc99c5c4d4eed293aab40d406 (patch) | |
tree | b9263249c6e8eccfaaab7ed9dc75986749da1080 /perllib/FixMyStreet/DB/Result/Body.pm | |
parent | 3e30cee562d3eae98d73e63dc2d9708b09e24e81 (diff) |
Allow bodies to have parent bodies.
Diffstat (limited to 'perllib/FixMyStreet/DB/Result/Body.pm')
-rw-r--r-- | perllib/FixMyStreet/DB/Result/Body.pm | 27 |
1 files changed, 23 insertions, 4 deletions
diff --git a/perllib/FixMyStreet/DB/Result/Body.pm b/perllib/FixMyStreet/DB/Result/Body.pm index a4da74f80..27ea1897e 100644 --- a/perllib/FixMyStreet/DB/Result/Body.pm +++ b/perllib/FixMyStreet/DB/Result/Body.pm @@ -18,6 +18,8 @@ __PACKAGE__->add_columns( is_nullable => 0, sequence => "body_id_seq", }, + "name", + { data_type => "text", is_nullable => 0 }, "endpoint", { data_type => "text", is_nullable => 1 }, "jurisdiction", @@ -34,11 +36,17 @@ __PACKAGE__->add_columns( { data_type => "boolean", default_value => \"false", is_nullable => 0 }, "can_be_devolved", { data_type => "boolean", default_value => \"false", is_nullable => 0 }, - "name", - { data_type => "text", is_nullable => 0 }, + "parent", + { data_type => "integer", is_foreign_key => 1, is_nullable => 1 }, ); __PACKAGE__->set_primary_key("id"); __PACKAGE__->has_many( + "bodies", + "FixMyStreet::DB::Result::Body", + { "foreign.parent" => "self.id" }, + { cascade_copy => 0, cascade_delete => 0 }, +); +__PACKAGE__->has_many( "body_areas", "FixMyStreet::DB::Result::BodyArea", { "foreign.body_id" => "self.id" }, @@ -61,6 +69,17 @@ __PACKAGE__->has_many( { "foreign.body_id" => "self.id" }, { cascade_copy => 0, cascade_delete => 0 }, ); +__PACKAGE__->belongs_to( + "parent", + "FixMyStreet::DB::Result::Body", + { id => "parent" }, + { + is_deferrable => 1, + join_type => "LEFT", + on_delete => "CASCADE", + on_update => "CASCADE", + }, +); __PACKAGE__->has_many( "users", "FixMyStreet::DB::Result::User", @@ -69,8 +88,8 @@ __PACKAGE__->has_many( ); -# Created by DBIx::Class::Schema::Loader v0.07017 @ 2012-12-14 17:54:33 -# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:2Z3gCosNomCTcjrwWy/RNA +# Created by DBIx::Class::Schema::Loader v0.07017 @ 2012-12-19 12:47:10 +# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:DdtXjMWRpz20ZHjtY3oP2w sub url { my ( $self, $c ) = @_; |