From: Don Armstrong Date: Sat, 24 Sep 2016 21:53:31 +0000 (-0700) Subject: add usertag support to the database X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=c8690ed41732f180f9340917d567cbda827e79be;p=debbugs.git add usertag support to the database --- diff --git a/Debbugs/DB.pm b/Debbugs/DB.pm index 313bfbb3..c3937444 100644 --- a/Debbugs/DB.pm +++ b/Debbugs/DB.pm @@ -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 diff --git a/Debbugs/DB/Result/Bug.pm b/Debbugs/DB/Result/Bug.pm index 555c2d7d..4a487825 100644 --- a/Debbugs/DB/Result/Bug.pm +++ b/Debbugs/DB/Result/Bug.pm @@ -408,6 +408,21 @@ __PACKAGE__->has_many( { cascade_copy => 0, cascade_delete => 0 }, ); +=head2 bug_user_tags + +Type: has_many + +Related object: L + +=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 index 00000000..3363b621 --- /dev/null +++ b/Debbugs/DB/Result/BugUserTag.pm @@ -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 + +=item * L + +=back + +=cut + +__PACKAGE__->load_components("InflateColumn::DateTime", "TimeStamp"); + +=head1 TABLE: C + +=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 + +=back + +=cut + +__PACKAGE__->set_primary_key("id"); + +=head1 UNIQUE CONSTRAINTS + +=head2 C + +=over 4 + +=item * L + +=item * L + +=back + +=cut + +__PACKAGE__->add_unique_constraint("bug_user_tag_bug_tag", ["bug", "user_tag"]); + +=head1 RELATIONS + +=head2 bug + +Type: belongs_to + +Related object: L + +=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 + +=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; diff --git a/Debbugs/DB/Result/Correspondent.pm b/Debbugs/DB/Result/Correspondent.pm index 68ed39d9..b0a57ae0 100644 --- a/Debbugs/DB/Result/Correspondent.pm +++ b/Debbugs/DB/Result/Correspondent.pm @@ -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 + +=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 index 00000000..2ced7917 --- /dev/null +++ b/Debbugs/DB/Result/UserTag.pm @@ -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 + +=item * L + +=back + +=cut + +__PACKAGE__->load_components("InflateColumn::DateTime", "TimeStamp"); + +=head1 TABLE: C + +=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 + +=back + +=cut + +__PACKAGE__->set_primary_key("id"); + +=head1 UNIQUE CONSTRAINTS + +=head2 C + +=over 4 + +=item * L + +=item * L + +=back + +=cut + +__PACKAGE__->add_unique_constraint("user_tag_tag_correspondent", ["tag", "correspondent"]); + +=head1 RELATIONS + +=head2 bug_user_tags + +Type: has_many + +Related object: L + +=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 + +=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; diff --git a/sql/debbugs_schema.sql b/sql/debbugs_schema.sql index ff1121ba..02529ed2 100644 --- a/sql/debbugs_schema.sql +++ b/sql/debbugs_schema.sql @@ -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,