diff options
Diffstat (limited to 'Bugzilla')
-rw-r--r-- | Bugzilla/DB/Schema.pm | 2 | ||||
-rw-r--r-- | Bugzilla/Install/DB.pm | 18 |
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__ |