From: Don Armstrong Date: Fri, 14 Apr 2017 16:11:26 +0000 (-0700) Subject: Update DB Schema version to 6 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=ab9e98d16efa43c321cf298bb3aa1347b216e53f;p=debbugs.git Update DB Schema version to 6 + Add all of the missing indexes to sqlt_deploy_hooks + Remake bug_package view to include affects + dd missing asof index on bug_status_cache --- diff --git a/Debbugs/DB.pm b/Debbugs/DB.pm index 656ff00c..29abb21e 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=5; +our $VERSION=6; # You can replace this text with custom code or comments, and it will be preserved on regeneration diff --git a/Debbugs/DB/Result/BinVer.pm b/Debbugs/DB/Result/BinVer.pm index df90ebfb..5c113da0 100644 --- a/Debbugs/DB/Result/BinVer.pm +++ b/Debbugs/DB/Result/BinVer.pm @@ -194,5 +194,15 @@ __PACKAGE__->belongs_to( # DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:DzTzZbPkilT8WMhXoZv9xw -# You can replace this text with custom code or comments, and it will be preserved on regeneration +sub sqlt_deploy_hook { + my ($self, $sqlt_table) = @_; + for my $idx (qw(var bin_pkg src_ver)) { + $sqlt_table->add_index(name => 'bin_ver_'.$idx.'_id_idx', + fields => [$idx]); + } + $sqlt_table->add_index(name => 'bin_ver_src_ver_id_arch_idx', + fields => [qw(src_ver arch)] + ); +} + 1; diff --git a/Debbugs/DB/Result/Bug.pm b/Debbugs/DB/Result/Bug.pm index d6e0f3d6..1cb210de 100644 --- a/Debbugs/DB/Result/Bug.pm +++ b/Debbugs/DB/Result/Bug.pm @@ -526,6 +526,24 @@ __PACKAGE__->many_to_many(affects_binpackages => 'bug_affects_binpackages','bin_ __PACKAGE__->many_to_many(affects_srcpackages => 'bug_affects_srcpackages','src_pkg'); __PACKAGE__->many_to_many(messages => 'bug_messages','message'); +sub sqlt_deploy_hook { + my ($self, $sqlt_table) = @_; + # CREATE INDEX bug_idx_owner ON bug(owner); + # CREATE INDEX bug_idx_submitter ON bug(submitter); + # CREATE INDEX bug_idx_done ON bug(done); + # CREATE INDEX bug_idx_forwarded ON bug(forwarded); + # CREATE INDEX bug_idx_last_modified ON bug(last_modified); + # CREATE INDEX bug_idx_severity ON bug(severity); + # CREATE INDEX bug_idx_creation ON bug(creation); + # CREATE INDEX bug_idx_log_modified ON bug(log_modified); + for my $idx (qw(owner submitter done forwarded last_modified), + qw(severity creation log_modified), + ) { + $sqlt_table->add_index(name => 'bug_idx'.$idx, + fields => [$idx]); + } +} + sub set_related_packages { my ($self,$relationship,$pkgs,$pkg_cache) = @_; diff --git a/Debbugs/DB/Result/BugBinpackage.pm b/Debbugs/DB/Result/BugBinpackage.pm index 869ce26d..d5729949 100644 --- a/Debbugs/DB/Result/BugBinpackage.pm +++ b/Debbugs/DB/Result/BugBinpackage.pm @@ -115,5 +115,11 @@ __PACKAGE__->belongs_to( # DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:wL+pwSCfWe/mMQOjziKSeg -# You can replace this text with custom code or comments, and it will be preserved on regeneration +sub sqlt_deploy_hook { + my ($self, $sqlt_table) = @_; + $sqlt_table->add_index(name => 'bug_binpackage_bin_pkg_idx', + fields => [qw(bin_pkg)], + ); +} + 1; diff --git a/Debbugs/DB/Result/BugBlock.pm b/Debbugs/DB/Result/BugBlock.pm index 467ab684..0200a313 100644 --- a/Debbugs/DB/Result/BugBlock.pm +++ b/Debbugs/DB/Result/BugBlock.pm @@ -141,5 +141,12 @@ __PACKAGE__->belongs_to( # DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:Rkt0XlA4r2YFX0KnUZmS6A -# You can replace this text with custom code or comments, and it will be preserved on regeneration +sub sqlt_deploy_hook { + my ($self, $sqlt_table) = @_; + for my $idx (qw(bug blocks)) { + $sqlt_table->add_index(name => 'bug_blocks_'.$idx.'_idx', + fields => [$idx]); + } +} + 1; diff --git a/Debbugs/DB/Result/BugMerged.pm b/Debbugs/DB/Result/BugMerged.pm index 405b4482..477919bc 100644 --- a/Debbugs/DB/Result/BugMerged.pm +++ b/Debbugs/DB/Result/BugMerged.pm @@ -140,6 +140,12 @@ __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:HdGeCb1Fh2cU08+TTQVi/Q +sub sqlt_deploy_hook { + my ($self, $sqlt_table) = @_; + for my $idx (qw(bug merged)) { + $sqlt_table->add_index(name => 'bug_merged_'.$idx.'_idx', + fields => [$idx]); + } +} -# You can replace this text with custom code or comments, and it will be preserved on regeneration 1; diff --git a/Debbugs/DB/Result/BugMessage.pm b/Debbugs/DB/Result/BugMessage.pm index cf5b193a..b5fccc55 100644 --- a/Debbugs/DB/Result/BugMessage.pm +++ b/Debbugs/DB/Result/BugMessage.pm @@ -141,6 +141,10 @@ __PACKAGE__->belongs_to( # Created by DBIx::Class::Schema::Loader v0.07046 @ 2017-03-04 10:59:03 # DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:BRbN9C6P/wvWWmSmjNGjLA - -# You can replace this text with custom code or comments, and it will be preserved on regeneration +sub sqlt_deploy_hook { + my ($self, $sqlt_table) = @_; + $sqlt_table->add_index(name => 'bug_message_idx_bug_message_number', + fields => [qw(bug message_number)], + ); +} 1; diff --git a/Debbugs/DB/Result/BugPackage.pm b/Debbugs/DB/Result/BugPackage.pm index 9019fcae..db6f2005 100644 --- a/Debbugs/DB/Result/BugPackage.pm +++ b/Debbugs/DB/Result/BugPackage.pm @@ -35,7 +35,7 @@ __PACKAGE__->table_class("DBIx::Class::ResultSource::View"); =cut __PACKAGE__->table("bug_package"); -__PACKAGE__->result_source_instance->view_definition(" SELECT b.bug,\n b.bin_pkg AS pkg_id,\n 'binary'::text AS pkg_type,\n bp.pkg AS package\n FROM (bug_binpackage b\n JOIN bin_pkg bp ON ((bp.id = b.bin_pkg)))\nUNION\n SELECT s.bug,\n s.src_pkg AS pkg_id,\n 'source'::text AS pkg_type,\n sp.pkg AS package\n FROM (bug_srcpackage s\n JOIN src_pkg sp ON ((sp.id = s.src_pkg)))"); +__PACKAGE__->result_source_instance->view_definition(" SELECT b.bug,\n b.bin_pkg AS pkg_id,\n 'binary'::text AS pkg_type,\n bp.pkg AS package\n FROM (bug_binpackage b\n JOIN bin_pkg bp ON ((bp.id = b.bin_pkg)))\nUNION\n SELECT s.bug,\n s.src_pkg AS pkg_id,\n 'source'::text AS pkg_type,\n sp.pkg AS package\n FROM (bug_srcpackage s\n JOIN src_pkg sp ON ((sp.id = s.src_pkg)))\nUNION\n SELECT b.bug,\n b.bin_pkg AS pkg_id,\n 'binary_affects'::text AS pkg_type,\n bp.pkg AS package\n FROM (bug_affects_binpackage b\n JOIN bin_pkg bp ON ((bp.id = b.bin_pkg)))\nUNION\n SELECT s.bug,\n s.src_pkg AS pkg_id,\n 'source_affects'::text AS pkg_type,\n sp.pkg AS package\n FROM (bug_affects_srcpackage s\n JOIN src_pkg sp ON ((sp.id = s.src_pkg)))"); =head1 ACCESSORS @@ -73,8 +73,8 @@ __PACKAGE__->add_columns( ); -# Created by DBIx::Class::Schema::Loader v0.07046 @ 2017-03-04 10:59:03 -# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:+zeVIVZOYSZjTkD+1N2sdw +# Created by DBIx::Class::Schema::Loader v0.07046 @ 2017-04-13 11:30:02 +# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:2Nrl+KO8b94gK5GcCkdNcw __PACKAGE__->result_source_instance->view_definition(<belongs_to( # Created by DBIx::Class::Schema::Loader v0.07046 @ 2017-03-04 10:59:03 # DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:5SduyMaGHABDrX19Cxg4fg +sub sqlt_deploy_hook { + my ($self, $sqlt_table) = @_; + $sqlt_table->add_index(name => 'bug_srcpackage_src_pkg_idx', + fields => [qw(src_pkg)], + ); +} -# You can replace this text with custom code or comments, and it will be preserved on regeneration 1; diff --git a/Debbugs/DB/Result/BugTag.pm b/Debbugs/DB/Result/BugTag.pm index 15e5c3a4..f5c6c24f 100644 --- a/Debbugs/DB/Result/BugTag.pm +++ b/Debbugs/DB/Result/BugTag.pm @@ -115,5 +115,11 @@ __PACKAGE__->belongs_to( # DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:yyHP5f8zAxn/AdjOCr8WAg -# You can replace this text with custom code or comments, and it will be preserved on regeneration +sub sqlt_deploy_hook { + my ($self, $sqlt_table) = @_; + $sqlt_table->add_index(name => 'bug_tag_tag', + fields => [qw(tag)], + ); +} + 1; diff --git a/Debbugs/DB/Result/BugUserTag.pm b/Debbugs/DB/Result/BugUserTag.pm index 113a36a1..6d83c63a 100644 --- a/Debbugs/DB/Result/BugUserTag.pm +++ b/Debbugs/DB/Result/BugUserTag.pm @@ -113,5 +113,11 @@ __PACKAGE__->belongs_to( # DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:jZngUCQ1eBBcfXd/jWCKGA -# You can replace this text with custom code or comments, and it will be preserved on regeneration +sub sqlt_deploy_hook { + my ($self, $sqlt_table) = @_; + $sqlt_table->add_index(name => 'bug_user_tag_tag', + fields => [qw(user_tag)], + ); +} + 1; diff --git a/Debbugs/DB/Result/BugVer.pm b/Debbugs/DB/Result/BugVer.pm index 3de7f4cf..f50cf623 100644 --- a/Debbugs/DB/Result/BugVer.pm +++ b/Debbugs/DB/Result/BugVer.pm @@ -234,5 +234,14 @@ __PACKAGE__->belongs_to( # DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:cvdjFL2o+rBg2PfcintuNA -# You can replace this text with custom code or comments, and it will be preserved on regeneration +sub sqlt_deploy_hook { + my ($self, $sqlt_table) = @_; + for my $idx (qw(src_pkg src_ver)) { + $sqlt_table->add_index(name => 'bug_ver_'.$idx.'_id_idx', + fields => [$idx]); + } + $sqlt_table->add_index(name => 'bug_ver_src_pkg_id_src_ver_id_idx', + fields => [qw(src_pkg src_var)], + ); +} 1; diff --git a/Debbugs/DB/Result/CorrespondentFullName.pm b/Debbugs/DB/Result/CorrespondentFullName.pm index 107e10b8..c5a28ec5 100644 --- a/Debbugs/DB/Result/CorrespondentFullName.pm +++ b/Debbugs/DB/Result/CorrespondentFullName.pm @@ -115,6 +115,12 @@ __PACKAGE__->belongs_to( # Created by DBIx::Class::Schema::Loader v0.07046 @ 2017-03-04 10:59:03 # DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:2Ac8mrDV2IsE/11YsYoqQQ +sub sqlt_deploy_hook { + my ($self, $sqlt_table) = @_; + for my $idx (qw(correspondent message)) { + $sqlt_table->add_index(name => 'message_correspondent_idx'.$idx, + fields => [$idx]); + } +} -# You can replace this text with custom code or comments, and it will be preserved on regeneration 1; diff --git a/Debbugs/DB/Result/Maintainer.pm b/Debbugs/DB/Result/Maintainer.pm index 9157653c..d8c04ec8 100644 --- a/Debbugs/DB/Result/Maintainer.pm +++ b/Debbugs/DB/Result/Maintainer.pm @@ -171,6 +171,11 @@ __PACKAGE__->has_many( # Created by DBIx::Class::Schema::Loader v0.07042 @ 2014-11-30 21:56:51 # DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:rkpgeXltH2wiC1Us7FIijw +sub sqlt_deploy_hook { + my ($self, $sqlt_table) = @_; + $sqlt_table->add_index(name => 'maintainer_idx_correspondent', + fields => [qw(correspondent)], + ); +} -# You can replace this text with custom code or comments, and it will be preserved on regeneration 1; diff --git a/Debbugs/DB/Result/Message.pm b/Debbugs/DB/Result/Message.pm index 0ac17aa5..cd42f48e 100644 --- a/Debbugs/DB/Result/Message.pm +++ b/Debbugs/DB/Result/Message.pm @@ -243,5 +243,13 @@ __PACKAGE__->many_to_many(correspondents => 'message_correspondents','correspond __PACKAGE__->many_to_many(references => 'message_refs_message','message'); __PACKAGE__->many_to_many(referenced_by => 'message_refs_refs','message'); -# You can replace this text with custom code or comments, and it will be preserved on regeneration + +sub sqlt_deploy_hook { + my ($self, $sqlt_table) = @_; + for my $idx (qw(msgid subject)) { + $sqlt_table->add_index(name => 'message_'.$idx.'_idx', + fields => [$idx]); + } +} + 1; diff --git a/Debbugs/DB/Result/MessageRef.pm b/Debbugs/DB/Result/MessageRef.pm index 8d695b77..98e2a2d8 100644 --- a/Debbugs/DB/Result/MessageRef.pm +++ b/Debbugs/DB/Result/MessageRef.pm @@ -134,6 +134,12 @@ __PACKAGE__->belongs_to( # Created by DBIx::Class::Schema::Loader v0.07046 @ 2017-03-04 10:59:03 # DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:0YaAP/sB5N2Xr2rAFNK1lg +sub sqlt_deploy_hook { + my ($self, $sqlt_table) = @_; + for my $idx (qw(refs message)) { + $sqlt_table->add_index(name => 'message_refs_idx_'.$idx, + fields => [$idx]); + } +} -# You can replace this text with custom code or comments, and it will be preserved on regeneration 1; diff --git a/Debbugs/DB/Result/Severity.pm b/Debbugs/DB/Result/Severity.pm index c31b6e6d..edea9a96 100644 --- a/Debbugs/DB/Result/Severity.pm +++ b/Debbugs/DB/Result/Severity.pm @@ -144,6 +144,11 @@ __PACKAGE__->has_many( # Created by DBIx::Class::Schema::Loader v0.07042 @ 2014-11-30 21:56:51 # DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:nI4ZqWa6IW7LgWuG7S1Gog +sub sqlt_deploy_hook { + my ($self, $sqlt_table) = @_; + $sqlt_table->add_index(name => 'severity_ordering_idx', + fields => [qw(ordering)], + ); +} -# You can replace this text with custom code or comments, and it will be preserved on regeneration 1; diff --git a/Debbugs/DB/Result/SrcPkg.pm b/Debbugs/DB/Result/SrcPkg.pm index 10266fa5..fc6b2e1a 100644 --- a/Debbugs/DB/Result/SrcPkg.pm +++ b/Debbugs/DB/Result/SrcPkg.pm @@ -263,5 +263,10 @@ __PACKAGE__->has_many( # DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:j8LGu4eUfNUNxM/jkHUG2A -# You can replace this text with custom code or comments, and it will be preserved on regeneration +sub sqlt_deploy_hook { + my ($self, $sqlt_table) = @_; + $sqlt_table->add_index(name => 'src_pkg_pkg', + fields => 'pkg', + ); +} 1; diff --git a/Debbugs/DB/Result/UserTag.pm b/Debbugs/DB/Result/UserTag.pm index 2ced7917..0883a2e5 100644 --- a/Debbugs/DB/Result/UserTag.pm +++ b/Debbugs/DB/Result/UserTag.pm @@ -141,6 +141,11 @@ __PACKAGE__->belongs_to( # Created by DBIx::Class::Schema::Loader v0.07045 @ 2016-09-24 14:51:07 # DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:ZPmTBeTue62dG2NdQdPrQg +sub sqlt_deploy_hook { + my ($self, $sqlt_table) = @_; + $sqlt_table->add_index(name => 'user_tag_correspondent', + fields => [qw(correspondent)], + ); +} -# 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 7badd772..a9d22325 100644 --- a/sql/debbugs_schema.sql +++ b/sql/debbugs_schema.sql @@ -350,10 +350,6 @@ INSERT INTO table_comments VALUES ('bug_srcpackage','Bug <-> source package mapp INSERT INTO column_comments VALUES ('bug_srcpackage','bug','Bug id (matches bug)'); INSERT INTO column_comments VALUES ('bug_srcpackage','src_pkg','Source package id (matches src_pkg)'); -CREATE VIEW bug_package (bug,pkg_id,pkg_type,package) AS - SELECT b.bug,b.bin_pkg,'binary',bp.pkg FROM bug_binpackage b JOIN bin_pkg bp ON bp.id=b.bin_pkg UNION - SELECT s.bug,s.src_pkg,'source',sp.pkg FROM bug_srcpackage s JOIN src_pkg sp ON sp.id=s.src_pkg; - CREATE TABLE bug_affects_binpackage ( bug INT NOT NULL REFERENCES bug, bin_pkg INT NOT NULL REFERENCES bin_pkg ON UPDATE CASCADE ON DELETE CASCADE @@ -372,6 +368,12 @@ INSERT INTO table_comments VALUES ('bug_affects_srcpackage','Bug <-> source pack INSERT INTO column_comments VALUES ('bug_affects_srcpackage','bug','Bug id (matches bug)'); INSERT INTO column_comments VALUES ('bug_affects_srcpackage','src_pkg','Source package id (matches src_pkg)'); +CREATE VIEW bug_package (bug,pkg_id,pkg_type,package) AS + SELECT b.bug,b.bin_pkg,'binary',bp.pkg FROM bug_binpackage b JOIN bin_pkg bp ON bp.id=b.bin_pkg UNION + SELECT s.bug,s.src_pkg,'source',sp.pkg FROM bug_srcpackage s JOIN src_pkg sp ON sp.id=s.src_pkg UNION + SELECT b.bug,b.bin_pkg,'binary_affects',bp.pkg FROM bug_affects_binpackage b JOIN bin_pkg bp ON bp.id=b.bin_pkg UNION + SELECT s.bug,s.src_pkg,'source_affects',sp.pkg FROM bug_affects_srcpackage s JOIN src_pkg sp ON sp.id=s.src_pkg; + CREATE VIEW binary_versions (src_pkg, src_ver, bin_pkg, arch, bin_ver) AS SELECT sp.pkg AS src_pkg, sv.ver AS src_ver, bp.pkg AS bin_pkg, a.arch AS arch, b.ver AS bin_ver, svb.ver AS src_ver_based_on, spb.pkg AS src_pkg_based_on @@ -443,6 +445,7 @@ CREATE INDEX bug_status_cache_idx_bug ON bug_status_cache(bug); CREATE INDEX bug_status_cache_idx_status ON bug_status_cache(status); CREATE INDEX bug_status_cache_idx_arch ON bug_status_cache(arch); CREATE INDEX bug_status_cache_idx_suite ON bug_status_cache(suite); +CREATE INDEX bug_status_cache_idx_asof ON bug_status_cache(asof); INSERT INTO table_comments VALUES ('bug_status_cache','Bug Status Cache'); INSERT INTO column_comments VALUES ('bug_status_cache','bug','Bug number (matches bug)'); INSERT INTO column_comments VALUES ('bug_status_cache','suite','Suite id (matches suite)');