diff options
author | Dave Lawrence <dlawrence@mozilla.com> | 2013-05-06 23:11:30 +0200 |
---|---|---|
committer | Dave Lawrence <dlawrence@mozilla.com> | 2013-05-06 23:11:30 +0200 |
commit | cf7d6aea1af628711f2c870cdc8607390c18089a (patch) | |
tree | 199b1c444e842e5f783d8fac9bbebc2360a1c55f /contrib | |
parent | bf36421e1a146eb02d3ea3e6f7f1c951023f2443 (diff) | |
download | bugzilla-cf7d6aea1af628711f2c870cdc8607390c18089a.tar.gz bugzilla-cf7d6aea1af628711f2c870cdc8607390c18089a.tar.xz |
Bug 868167 - Move the current cf_due_date from type DATETIME to DATE once bug 866248 has landed on prod
r=glob
Diffstat (limited to 'contrib')
-rwxr-xr-x | contrib/reorg-tools/convert_date_time_date.pl | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/contrib/reorg-tools/convert_date_time_date.pl b/contrib/reorg-tools/convert_date_time_date.pl new file mode 100755 index 000000000..aa3b58ca1 --- /dev/null +++ b/contrib/reorg-tools/convert_date_time_date.pl @@ -0,0 +1,58 @@ +#!/usr/bin/perl -w +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# +# This Source Code Form is "Incompatible With Secondary Licenses", as +# defined by the Mozilla Public License, v. 2.0. + +use strict; + +use Cwd 'abs_path'; +use File::Basename; +use FindBin; +use lib "$FindBin::Bin/../.."; +use lib "$FindBin::Bin/../../lib"; + +use Bugzilla; +use Bugzilla::Constants; + +sub usage() { + print <<USAGE; +Usage: convert_date_time_date.pl <column> + +E.g.: convert_date_time_date.pl cf_due_date +Converts a datetime field (FIELD_TYPE_DATETIME) to a date field type +(FIELD_TYPE_DATE). + +Note: Any time portion will be lost but the date portion will be preserved. +USAGE +} + +############################################################################# +# MAIN CODE +############################################################################# + +Bugzilla->usage_mode(USAGE_MODE_CMDLINE); + +if (scalar @ARGV < 1) { + usage(); + exit(); +} + +my $column = shift; + +print <<EOF; +Converting bugs.${column} from FIELD_TYPE_DATETIME to FIELD_TYPE_DATE. + +Note: Any time portion will be lost but the date portion will be preserved. + +Press <Ctrl-C> to stop or <Enter> to continue... +EOF +getc(); + +Bugzilla->dbh->bz_alter_column('bugs', $column, { TYPE => 'DATE' }); +Bugzilla->dbh->do("UPDATE fielddefs SET type = ? WHERE name = ?", + undef, FIELD_TYPE_DATE, $column); + +print "\ndone.\n"; |