diff options
author | ivan <ivan> | 2010-06-07 00:10:27 +0000 |
---|---|---|
committer | ivan <ivan> | 2010-06-07 00:10:27 +0000 |
commit | da99804133e55d5ce02402645b593a6de06d1947 (patch) | |
tree | da8e3e65f2801b2d3f8c60a48054350bfc12bd6b /FS | |
parent | 42ad860da02665aa21193d3bc418ef03e96727fb (diff) |
mysql compat: cgp_rule_condition s/condition/conditionname/
Diffstat (limited to 'FS')
-rw-r--r-- | FS/FS/Schema.pm | 2 | ||||
-rw-r--r-- | FS/FS/cgp_rule_condition.pm | 8 | ||||
-rwxr-xr-x | FS/bin/freeside-upgrade | 31 |
3 files changed, 34 insertions, 7 deletions
diff --git a/FS/FS/Schema.pm b/FS/FS/Schema.pm index 0b54282ef..859224fb0 100644 --- a/FS/FS/Schema.pm +++ b/FS/FS/Schema.pm @@ -1803,7 +1803,7 @@ sub tables_hashref { 'cgp_rule_condition' => { 'columns' => [ 'ruleconditionnum', 'serial', '', '', '', '', - 'condition', 'varchar', '', $char_d, '', '', + 'conditionname', 'varchar', '', $char_d, '', '', 'op', 'varchar', 'NULL', $char_d, '', '', 'params', 'varchar', 'NULL', 255, '', '', 'rulenum', 'int', '', '', '', '', diff --git a/FS/FS/cgp_rule_condition.pm b/FS/FS/cgp_rule_condition.pm index 02ea1729d..772e1899e 100644 --- a/FS/FS/cgp_rule_condition.pm +++ b/FS/FS/cgp_rule_condition.pm @@ -36,7 +36,7 @@ currently supported: primary key -=item condition +=item conditionname condition @@ -113,7 +113,7 @@ sub check { my $error = $self->ut_numbern('ruleconditionnum') - || $self->ut_text('condition') + || $self->ut_text('conditionname') || $self->ut_textn('op') || $self->ut_textn('params') || $self->ut_foreign_key('rulenum', 'cgp_rule', 'rulenum') @@ -125,13 +125,13 @@ sub check { =item arrayref -Returns an array reference of the condition, op and params fields. +Returns an array reference of the conditionname, op and params fields. =cut sub arrayref { my $self = shift; - [ map $self->$_, qw( condition op params ) ]; + [ map $self->$_, qw( conditionname op params ) ]; } =back diff --git a/FS/bin/freeside-upgrade b/FS/bin/freeside-upgrade index a0a5fe68c..4a6fac293 100755 --- a/FS/bin/freeside-upgrade +++ b/FS/bin/freeside-upgrade @@ -61,6 +61,33 @@ if (dbdef->table('cust_main')->column('agent_custid') && ! $opt_s) { if (dbdef->table('h_cust_main')); } +if ( dbdef->table('cgp_rule_condition') && + dbdef->table('cgp_rule_condition')->column('condition') + ) +{ + push @bugfix, + "ALTER TABLE ${_}cgp_rule_condition RENAME COLUMN condition TO conditionname" + for '', 'h_'; + +} + +if ( $DRY_RUN ) { + print + join(";\n", @bugfix ). ";\n"; +} elsif ( @bugfix ) { + + foreach my $statement ( @bugfix ) { + warn "$statement\n"; + $dbh->do( $statement ) + or die "Error: ". $dbh->errstr. "\n executing: $statement"; + } + + dbdef_create($dbh, $dbdef_file); + delete $FS::Schema::dbdef_cache{$dbdef_file}; #force an actual reload + reload_dbdef($dbdef_file); + +} + #you should have run fs-migrate-part_svc ages ago, when you upgraded #from 1.3 to 1.4... if not, it needs to be hooked into -upgrade here or #you'll lose all the part_svc settings it migrates to part_svc_column @@ -83,10 +110,10 @@ unless ( driver_name =~ /^mysql/i ) { if ( $DRY_RUN ) { print - join(";\n", @bugfix, @statements ). ";\n"; + join(";\n", @statements ). ";\n"; exit; } else { - foreach my $statement ( @bugfix, @statements ) { + foreach my $statement ( @statements ) { warn "$statement\n"; $dbh->do( $statement ) or die "Error: ". $dbh->errstr. "\n executing: $statement"; |