]> git.donarmstrong.com Git - debbugs.git/blobdiff - Debbugs/DB/Result/SrcVer.pm
Merge branch 'mouseify'
[debbugs.git] / Debbugs / DB / Result / SrcVer.pm
index e9125ba8185d4bcfa409ad544c4b1812f6e01df5..4181c1ed49757cc9f2ba2bc432aa5d8a57e6352b 100644 (file)
@@ -6,7 +6,7 @@ package Debbugs::DB::Result::SrcVer;
 
 =head1 NAME
 
-Debbugs::DB::Result::SrcVer
+Debbugs::DB::Result::SrcVer - Source Package versions
 
 =cut
 
@@ -21,11 +21,13 @@ use base 'DBIx::Class::Core';
 
 =item * L<DBIx::Class::InflateColumn::DateTime>
 
+=item * L<DBIx::Class::TimeStamp>
+
 =back
 
 =cut
 
-__PACKAGE__->load_components("InflateColumn::DateTime");
+__PACKAGE__->load_components("InflateColumn::DateTime", "TimeStamp");
 
 =head1 TABLE: C<src_ver>
 
@@ -42,17 +44,31 @@ __PACKAGE__->table("src_ver");
   is_nullable: 0
   sequence: 'src_ver_id_seq'
 
-=head2 src_pkg_id
+Source package version id
+
+=head2 src_pkg
 
   data_type: 'integer'
   is_foreign_key: 1
   is_nullable: 0
 
+Source package id (matches src_pkg table)
+
 =head2 ver
 
-  data_type: 'text'
+  data_type: 'debversion'
   is_nullable: 0
 
+Version of the source package
+
+=head2 maintainer
+
+  data_type: 'integer'
+  is_foreign_key: 1
+  is_nullable: 1
+
+Maintainer id (matches maintainer table)
+
 =head2 upload_date
 
   data_type: 'timestamp with time zone'
@@ -60,12 +76,16 @@ __PACKAGE__->table("src_ver");
   is_nullable: 0
   original: {default_value => \"now()"}
 
+Date this version of the source package was uploaded
+
 =head2 based_on
 
   data_type: 'integer'
   is_foreign_key: 1
   is_nullable: 1
 
+Source package version this version is based on
+
 =cut
 
 __PACKAGE__->add_columns(
@@ -76,10 +96,12 @@ __PACKAGE__->add_columns(
     is_nullable       => 0,
     sequence          => "src_ver_id_seq",
   },
-  "src_pkg_id",
+  "src_pkg",
   { data_type => "integer", is_foreign_key => 1, is_nullable => 0 },
   "ver",
-  { data_type => "text", is_nullable => 0 },
+  { data_type => "debversion", is_nullable => 0 },
+  "maintainer",
+  { data_type => "integer", is_foreign_key => 1, is_nullable => 1 },
   "upload_date",
   {
     data_type     => "timestamp with time zone",
@@ -109,7 +131,7 @@ __PACKAGE__->set_primary_key("id");
 
 =over 4
 
-=item * L</src_pkg_id>
+=item * L</src_pkg>
 
 =item * L</ver>
 
@@ -117,7 +139,7 @@ __PACKAGE__->set_primary_key("id");
 
 =cut
 
-__PACKAGE__->add_unique_constraint("src_ver_src_pkg_id_ver", ["src_pkg_id", "ver"]);
+__PACKAGE__->add_unique_constraint("src_ver_src_pkg_id_ver", ["src_pkg", "ver"]);
 
 =head1 RELATIONS
 
@@ -134,7 +156,7 @@ __PACKAGE__->belongs_to(
   "Debbugs::DB::Result::SrcVer",
   { id => "based_on" },
   {
-    is_deferrable => 1,
+    is_deferrable => 0,
     join_type     => "LEFT",
     on_delete     => "CASCADE",
     on_update     => "CASCADE",
@@ -152,7 +174,7 @@ Related object: L<Debbugs::DB::Result::BinVer>
 __PACKAGE__->has_many(
   "bin_vers",
   "Debbugs::DB::Result::BinVer",
-  { "foreign.src_ver_id" => "self.id" },
+  { "foreign.src_ver" => "self.id" },
   { cascade_copy => 0, cascade_delete => 0 },
 );
 
@@ -167,7 +189,42 @@ Related object: L<Debbugs::DB::Result::BugVer>
 __PACKAGE__->has_many(
   "bug_vers",
   "Debbugs::DB::Result::BugVer",
-  { "foreign.src_ver_id" => "self.id" },
+  { "foreign.src_ver" => "self.id" },
+  { cascade_copy => 0, cascade_delete => 0 },
+);
+
+=head2 maintainer
+
+Type: belongs_to
+
+Related object: L<Debbugs::DB::Result::Maintainer>
+
+=cut
+
+__PACKAGE__->belongs_to(
+  "maintainer",
+  "Debbugs::DB::Result::Maintainer",
+  { id => "maintainer" },
+  {
+    is_deferrable => 0,
+    join_type     => "LEFT",
+    on_delete     => "SET NULL",
+    on_update     => "CASCADE",
+  },
+);
+
+=head2 src_associations
+
+Type: has_many
+
+Related object: L<Debbugs::DB::Result::SrcAssociation>
+
+=cut
+
+__PACKAGE__->has_many(
+  "src_associations",
+  "Debbugs::DB::Result::SrcAssociation",
+  { "foreign.source" => "self.id" },
   { cascade_copy => 0, cascade_delete => 0 },
 );
 
@@ -182,8 +239,8 @@ Related object: L<Debbugs::DB::Result::SrcPkg>
 __PACKAGE__->belongs_to(
   "src_pkg",
   "Debbugs::DB::Result::SrcPkg",
-  { id => "src_pkg_id" },
-  { is_deferrable => 1, on_delete => "CASCADE", on_update => "CASCADE" },
+  { id => "src_pkg" },
+  { is_deferrable => 0, on_delete => "CASCADE", on_update => "CASCADE" },
 );
 
 =head2 src_vers
@@ -202,9 +259,27 @@ __PACKAGE__->has_many(
 );
 
 
-# Created by DBIx::Class::Schema::Loader v0.07025 @ 2012-07-17 17:10:22
-# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:sYRJ4htIIKwvuvbUemk90A
-
-
+# Created by DBIx::Class::Schema::Loader v0.07042 @ 2014-11-30 21:56:51
+# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:gY5LidUaQeuJ5AnN06CfKQ
+
+
+sub sqlt_deploy_hook {
+    my ($self, $sqlt_table) = @_;
+    $sqlt_table->schema->
+       add_procedure(name => 'src_ver_to_src_pkg',
+                     sql => <<'EOF',
+CREATE OR REPLACE FUNCTION src_ver_to_src_pkg(src_ver INT) RETURNS INT
+  AS $src_ver_to_src_pkg$
+  DECLARE
+  src_pkg int;
+  BEGIN
+       SELECT sv.src_pkg INTO STRICT src_pkg
+              FROM src_ver sv WHERE sv.id=src_ver;
+       RETURN src_pkg;
+  END
+  $src_ver_to_src_pkg$ LANGUAGE plpgsql;
+EOF
+                    );
+}
 # You can replace this text with custom code or comments, and it will be preserved on regeneration
 1;