]> git.donarmstrong.com Git - debbugs.git/commitdiff
add usertag support to the database
authorDon Armstrong <don@donarmstrong.com>
Sat, 24 Sep 2016 21:53:31 +0000 (14:53 -0700)
committerDon Armstrong <don@donarmstrong.com>
Sat, 24 Sep 2016 21:54:16 +0000 (14:54 -0700)
Debbugs/DB.pm
Debbugs/DB/Result/Bug.pm
Debbugs/DB/Result/BugUserTag.pm [new file with mode: 0644]
Debbugs/DB/Result/Correspondent.pm
Debbugs/DB/Result/UserTag.pm [new file with mode: 0644]
sql/debbugs_schema.sql

index 313bfbb35d70b337ae9e1eca9846dc5026e711eb..c3937444e03a8862781a0aba15ecfc311fe938e5 100644 (file)
@@ -17,7 +17,7 @@ __PACKAGE__->load_namespaces;
 
 # This version must be incremented any time the schema changes so that
 # DBIx::Class::DeploymentHandler can do its work
-our $VERSION=2;
+our $VERSION=3;
 
 # You can replace this text with custom code or comments, and it will be preserved on regeneration
 
index 555c2d7d7961cf8c19efe573eb17d25e167ef15b..4a487825e6553d0132a02be2b622dfcc042c8baf 100644 (file)
@@ -408,6 +408,21 @@ __PACKAGE__->has_many(
   { cascade_copy => 0, cascade_delete => 0 },
 );
 
+=head2 bug_user_tags
+
+Type: has_many
+
+Related object: L<Debbugs::DB::Result::BugUserTag>
+
+=cut
+
+__PACKAGE__->has_many(
+  "bug_user_tags",
+  "Debbugs::DB::Result::BugUserTag",
+  { "foreign.bug" => "self.id" },
+  { cascade_copy => 0, cascade_delete => 0 },
+);
+
 =head2 bug_vers
 
 Type: has_many
@@ -499,8 +514,8 @@ __PACKAGE__->belongs_to(
 );
 
 
-# Created by DBIx::Class::Schema::Loader v0.07042 @ 2014-11-30 21:56:51
-# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:rd0pst8cgR9UPi092sJebw
+# Created by DBIx::Class::Schema::Loader v0.07045 @ 2016-09-24 14:51:07
+# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:iaipVETTaokcFNrICfIEAw
 
 # You can replace this text with custom code or comments, and it will be preserved on regeneration
 1;
diff --git a/Debbugs/DB/Result/BugUserTag.pm b/Debbugs/DB/Result/BugUserTag.pm
new file mode 100644 (file)
index 0000000..3363b62
--- /dev/null
@@ -0,0 +1,143 @@
+use utf8;
+package Debbugs::DB::Result::BugUserTag;
+
+# Created by DBIx::Class::Schema::Loader
+# DO NOT MODIFY THE FIRST PART OF THIS FILE
+
+=head1 NAME
+
+Debbugs::DB::Result::BugUserTag - Bug <-> user tag mapping
+
+=cut
+
+use strict;
+use warnings;
+
+use base '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<bug_user_tag>
+
+=cut
+
+__PACKAGE__->table("bug_user_tag");
+
+=head1 ACCESSORS
+
+=head2 id
+
+  data_type: 'integer'
+  is_auto_increment: 1
+  is_nullable: 0
+  sequence: 'bug_user_tag_id_seq'
+
+=head2 bug
+
+  data_type: 'integer'
+  is_foreign_key: 1
+  is_nullable: 0
+
+Bug id (matches bug)
+
+=head2 user_tag
+
+  data_type: 'integer'
+  is_foreign_key: 1
+  is_nullable: 0
+
+=cut
+
+__PACKAGE__->add_columns(
+  "id",
+  {
+    data_type         => "integer",
+    is_auto_increment => 1,
+    is_nullable       => 0,
+    sequence          => "bug_user_tag_id_seq",
+  },
+  "bug",
+  { data_type => "integer", is_foreign_key => 1, is_nullable => 0 },
+  "user_tag",
+  { data_type => "integer", is_foreign_key => 1, is_nullable => 0 },
+);
+
+=head1 PRIMARY KEY
+
+=over 4
+
+=item * L</id>
+
+=back
+
+=cut
+
+__PACKAGE__->set_primary_key("id");
+
+=head1 UNIQUE CONSTRAINTS
+
+=head2 C<bug_user_tag_bug_tag>
+
+=over 4
+
+=item * L</bug>
+
+=item * L</user_tag>
+
+=back
+
+=cut
+
+__PACKAGE__->add_unique_constraint("bug_user_tag_bug_tag", ["bug", "user_tag"]);
+
+=head1 RELATIONS
+
+=head2 bug
+
+Type: belongs_to
+
+Related object: L<Debbugs::DB::Result::Bug>
+
+=cut
+
+__PACKAGE__->belongs_to(
+  "bug",
+  "Debbugs::DB::Result::Bug",
+  { id => "bug" },
+  { is_deferrable => 0, on_delete => "NO ACTION", on_update => "NO ACTION" },
+);
+
+=head2 user_tag
+
+Type: belongs_to
+
+Related object: L<Debbugs::DB::Result::UserTag>
+
+=cut
+
+__PACKAGE__->belongs_to(
+  "user_tag",
+  "Debbugs::DB::Result::UserTag",
+  { id => "user_tag" },
+  { is_deferrable => 0, on_delete => "NO ACTION", on_update => "NO ACTION" },
+);
+
+
+# Created by DBIx::Class::Schema::Loader v0.07045 @ 2016-09-24 14:51:07
+# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:bczKcbFkWt98BDvXLdhpcg
+
+
+# You can replace this text with custom code or comments, and it will be preserved on regeneration
+1;
index 68ed39d961dbe8f55efbc6c4e82f5081eb0645c9..b0a57ae064159754b04a55df227e29fabd424c3f 100644 (file)
@@ -185,9 +185,24 @@ __PACKAGE__->has_many(
   { cascade_copy => 0, cascade_delete => 0 },
 );
 
+=head2 user_tags
 
-# Created by DBIx::Class::Schema::Loader v0.07042 @ 2014-11-30 21:56:51
-# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:lFyRZdUZXsbDv0Xc6c4cAQ
+Type: has_many
+
+Related object: L<Debbugs::DB::Result::UserTag>
+
+=cut
+
+__PACKAGE__->has_many(
+  "user_tags",
+  "Debbugs::DB::Result::UserTag",
+  { "foreign.correspondent" => "self.id" },
+  { cascade_copy => 0, cascade_delete => 0 },
+);
+
+
+# Created by DBIx::Class::Schema::Loader v0.07045 @ 2016-09-24 14:51:07
+# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:CUVcqt94wCYJOPbiPt00+Q
 
 
 # You can replace this text with custom code or comments, and it will be preserved on regeneration
diff --git a/Debbugs/DB/Result/UserTag.pm b/Debbugs/DB/Result/UserTag.pm
new file mode 100644 (file)
index 0000000..2ced791
--- /dev/null
@@ -0,0 +1,146 @@
+use utf8;
+package Debbugs::DB::Result::UserTag;
+
+# Created by DBIx::Class::Schema::Loader
+# DO NOT MODIFY THE FIRST PART OF THIS FILE
+
+=head1 NAME
+
+Debbugs::DB::Result::UserTag - User bug tags
+
+=cut
+
+use strict;
+use warnings;
+
+use base '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<user_tag>
+
+=cut
+
+__PACKAGE__->table("user_tag");
+
+=head1 ACCESSORS
+
+=head2 id
+
+  data_type: 'integer'
+  is_auto_increment: 1
+  is_nullable: 0
+  sequence: 'user_tag_id_seq'
+
+User bug tag id
+
+=head2 tag
+
+  data_type: 'text'
+  is_nullable: 0
+
+User bug tag name
+
+=head2 correspondent
+
+  data_type: 'integer'
+  is_foreign_key: 1
+  is_nullable: 0
+
+User bug tag correspondent
+
+=cut
+
+__PACKAGE__->add_columns(
+  "id",
+  {
+    data_type         => "integer",
+    is_auto_increment => 1,
+    is_nullable       => 0,
+    sequence          => "user_tag_id_seq",
+  },
+  "tag",
+  { data_type => "text", is_nullable => 0 },
+  "correspondent",
+  { data_type => "integer", is_foreign_key => 1, is_nullable => 0 },
+);
+
+=head1 PRIMARY KEY
+
+=over 4
+
+=item * L</id>
+
+=back
+
+=cut
+
+__PACKAGE__->set_primary_key("id");
+
+=head1 UNIQUE CONSTRAINTS
+
+=head2 C<user_tag_tag_correspondent>
+
+=over 4
+
+=item * L</tag>
+
+=item * L</correspondent>
+
+=back
+
+=cut
+
+__PACKAGE__->add_unique_constraint("user_tag_tag_correspondent", ["tag", "correspondent"]);
+
+=head1 RELATIONS
+
+=head2 bug_user_tags
+
+Type: has_many
+
+Related object: L<Debbugs::DB::Result::BugUserTag>
+
+=cut
+
+__PACKAGE__->has_many(
+  "bug_user_tags",
+  "Debbugs::DB::Result::BugUserTag",
+  { "foreign.user_tag" => "self.id" },
+  { cascade_copy => 0, cascade_delete => 0 },
+);
+
+=head2 correspondent
+
+Type: belongs_to
+
+Related object: L<Debbugs::DB::Result::Correspondent>
+
+=cut
+
+__PACKAGE__->belongs_to(
+  "correspondent",
+  "Debbugs::DB::Result::Correspondent",
+  { id => "correspondent" },
+  { is_deferrable => 0, on_delete => "NO ACTION", on_update => "NO ACTION" },
+);
+
+
+# Created by DBIx::Class::Schema::Loader v0.07045 @ 2016-09-24 14:51:07
+# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:ZPmTBeTue62dG2NdQdPrQg
+
+
+# You can replace this text with custom code or comments, and it will be preserved on regeneration
+1;
index ff1121baf1a0e89e0cdb626026e89390e823e329..02529ed2057b1dd756a9ab66b6eb10daaacda964 100644 (file)
@@ -4,6 +4,8 @@ DROP VIEW bug_package CASCADE;
 DROP VIEW binary_versions CASCADE;
 DROP TABLE bug_tag CASCADE;
 DROP TABLE tag CASCADE;
+DROP TABLE bug_user_tag CASCADE;
+DROP TABLE user_tag CASCADE;
 DROP TABLE severity CASCADE;
 DROP TABLE bug CASCADE;
 DROP TABLE src_pkg CASCADE;
@@ -303,7 +305,31 @@ CREATE UNIQUE INDEX bug_tag_bug_tag ON bug_tag (bug,tag);
 CREATE INDEX bug_tag_tag ON bug_tag (tag);
 CREATE INDEX bug_tag_bug ON bug_tag (bug);
 
+CREATE TABLE user_tag (
+       id SERIAL PRIMARY KEY,
+       tag TEXT NOT NULL,
+       correspondent INT NOT NULL REFERENCES correspondent(id)
+);
+INSERT INTO table_comments VALUES ('user_tag','User bug tags');
+INSERT INTO column_comments VALUES ('user_tag','id','User bug tag id');
+INSERT INTO column_comments VALUES ('user_tag','tag','User bug tag name');
+INSERT INTO column_comments VALUES ('user_tag','correspondent','User bug tag correspondent');
+
+CREATE UNIQUE INDEX user_tag_tag_correspondent ON user_tag(tag,correspondent);
+CREATE INDEX user_tag_correspondent ON user_tag(correspondent);
+
+CREATE TABLE bug_user_tag (
+       id SERIAL PRIMARY KEY,
+       bug INT NOT NULL REFERENCES bug,
+       user_tag INT NOT NULL REFERENCES user_tag
+);
+INSERT INTO table_comments VALUES ('bug_user_tag','Bug <-> user tag mapping');
+INSERT INTO column_comments VALUES ('bug_user_tag','bug','Bug id (matches bug)');
+INSERT INTO column_comments VALUES ('bug_user_tag','tag','User tag id (matches user_tag)');
 
+CREATE UNIQUE INDEX bug_user_tag_bug_tag ON bug_user_tag (bug,user_tag);
+CREATE INDEX bug_user_tag_tag ON bug_user_tag (user_tag);
+CREATE INDEX bug_user_tag_bug ON bug_user_tag (bug);
 
 CREATE TABLE bug_binpackage (
        id SERIAL PRIMARY KEY,