]> git.donarmstrong.com Git - debbugs.git/blobdiff - Debbugs/DB/Result/SrcVer.pm
add bin_pkg to src_pkg convenience linking table with triggers
[debbugs.git] / Debbugs / DB / Result / SrcVer.pm
index 0b86ceda1950466c6f6e44bd30e6e87cbed7e6a0..4181c1ed49757cc9f2ba2bc432aa5d8a57e6352b 100644 (file)
@@ -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>
 
@@ -59,7 +61,7 @@ Source package id (matches src_pkg table)
 
 Version of the source package
 
-=head2 maintainer_id
+=head2 maintainer
 
   data_type: 'integer'
   is_foreign_key: 1
@@ -98,7 +100,7 @@ __PACKAGE__->add_columns(
   { data_type => "integer", is_foreign_key => 1, is_nullable => 0 },
   "ver",
   { data_type => "debversion", is_nullable => 0 },
-  "maintainer_id",
+  "maintainer",
   { data_type => "integer", is_foreign_key => 1, is_nullable => 1 },
   "upload_date",
   {
@@ -154,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",
@@ -172,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 },
 );
 
@@ -187,7 +189,7 @@ 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 },
 );
 
@@ -202,11 +204,11 @@ Related object: L<Debbugs::DB::Result::Maintainer>
 __PACKAGE__->belongs_to(
   "maintainer",
   "Debbugs::DB::Result::Maintainer",
-  { id => "maintainer_id" },
+  { id => "maintainer" },
   {
-    is_deferrable => 1,
+    is_deferrable => 0,
     join_type     => "LEFT",
-    on_delete     => "CASCADE",
+    on_delete     => "SET NULL",
     on_update     => "CASCADE",
   },
 );
@@ -238,7 +240,7 @@ __PACKAGE__->belongs_to(
   "src_pkg",
   "Debbugs::DB::Result::SrcPkg",
   { id => "src_pkg" },
-  { is_deferrable => 1, on_delete => "CASCADE", on_update => "CASCADE" },
+  { is_deferrable => 0, on_delete => "CASCADE", on_update => "CASCADE" },
 );
 
 =head2 src_vers
@@ -257,9 +259,27 @@ __PACKAGE__->has_many(
 );
 
 
-# Created by DBIx::Class::Schema::Loader v0.07025 @ 2013-03-25 18:43:53
-# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:I9bHyZBAJim7KZNk9Yd6Vw
-
-
+# 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;