summaryrefslogtreecommitdiffstats
path: root/Bugzilla
diff options
context:
space:
mode:
authorByron Jones <glob@mozilla.com>2015-07-09 08:24:47 +0200
committerByron Jones <glob@mozilla.com>2015-07-09 08:24:47 +0200
commit28ac958d3cf5951a2e75d53581d6ddd4ded30119 (patch)
tree7414367c927ef0784ba5dd25426ed7f83d5f5053 /Bugzilla
parentcd60ea7d685158bf9b024ccf940af3835a6a769c (diff)
downloadbugzilla-28ac958d3cf5951a2e75d53581d6ddd4ded30119.tar.gz
bugzilla-28ac958d3cf5951a2e75d53581d6ddd4ded30119.tar.xz
Bug 1180570: store attachment size in the database
Diffstat (limited to 'Bugzilla')
-rw-r--r--Bugzilla/DB/Schema.pm2
-rw-r--r--Bugzilla/Install/DB.pm18
2 files changed, 20 insertions, 0 deletions
diff --git a/Bugzilla/DB/Schema.pm b/Bugzilla/DB/Schema.pm
index bb874cd27..63bc1c034 100644
--- a/Bugzilla/DB/Schema.pm
+++ b/Bugzilla/DB/Schema.pm
@@ -512,6 +512,8 @@ use constant ABSTRACT_SCHEMA => {
DEFAULT => 'FALSE'},
isprivate => {TYPE => 'BOOLEAN', NOTNULL => 1,
DEFAULT => 'FALSE'},
+ attach_size => {TYPE => 'INT4', NOTNULL => 1,
+ DEFAULT => 0},
],
INDEXES => [
attachments_bug_id_idx => ['bug_id'],
diff --git a/Bugzilla/Install/DB.pm b/Bugzilla/Install/DB.pm
index 7e7362443..92015f22f 100644
--- a/Bugzilla/Install/DB.pm
+++ b/Bugzilla/Install/DB.pm
@@ -730,6 +730,8 @@ sub update_table_definitions {
$dbh->bz_add_index('user_api_keys', 'user_api_keys_user_id_app_id_idx',
[qw(user_id app_id)]);
+ _add_attach_size();
+
################################################################
# New --TABLE-- changes should go *** A B O V E *** this point #
################################################################
@@ -3829,6 +3831,22 @@ sub _fix_user_api_keys_indexes {
}
}
+sub _add_attach_size {
+ my $dbh = Bugzilla->dbh;
+
+ return if $dbh->bz_column_info('attachments', 'attach_size');
+
+ $dbh->bz_add_column('attachments', 'attach_size',
+ {TYPE => 'INT4', NOTNULL => 1, DEFAULT => 0});
+
+ print "Setting attach_size...\n";
+ $dbh->do("
+ UPDATE attachments
+ INNER JOIN attach_data ON attach_data.id = attachments.attach_id
+ SET attachments.attach_size = LENGTH(attach_data.thedata)
+ ");
+}
+
1;
__END__