[freeside-users] import 3.6git database into 4.1 ?

Ian Fraser ian_fraser at gozoom.ca
Sat Dec 10 14:03:44 PST 2016


Manually creating the password_history table using the info from the dryrun

CREATE TABLE password_history (
   passwordnum serial NOT NULL  ,
   _password varchar(80)   ,
   encryption_method varchar(80)   ,
   created int   ,
   svc_acct__svcnum int   ,
   svc_dsl__svcnum int   ,
   svc_alarm__svcnum int   ,
   agent__agentnum int   ,
   contact__contactnum int   ,
   access_user__usernum int   ,
   PRIMARY KEY (passwordnum)
)
;

Allows the upgrade to continue until it gets to upgrading cust_main  
where it dies on a non-unique key.  However the Record referred to IS 
unique as below:

head  /tmp/cust_location.csv
locationnum,prospectnum,custnum,address1,address2,city,county,state,zip,latitude,longitude,coord_auto,addr_clean,country,geocode,district,censustract,censusyear,location_type,location_number,location_kind,disabled,locationname,incorporated

sort /tmp/cust_location.csv | grep 6, | more

650,,1643,1272 
info,,removed,,ON,NOJ1GO,99.5616175,-96.9577946,Y,,CA,,,,,,,,,,
6,,5,145 noway 
,,Dallas,,CA,78945,43.0119437,-84.7411244,Y,,US,,,,,,,,,,   (this is the 
actual record as it is test data)
653,,1646,1144 
moreinfo,,nowhere,,ON,T4L3M9,35.5265261,-86.8689038,Y,,CA,,,,,,,,,,

<-----SNIP------>

tail of upgrade output

ALTER TABLE cust_main_exemption ADD FOREIGN KEY ( custnum ) REFERENCES 
cust_main ( custnum )
ALTER TABLE part_pkg_usageprice ADD FOREIGN KEY ( pkgpart ) REFERENCES 
part_pkg ( pkgpart )
ALTER TABLE cust_class ADD FOREIGN KEY ( categorynum ) REFERENCES 
cust_category ( categorynum )
ALTER TABLE cust_bill_batch_option ADD FOREIGN KEY ( billbatchnum ) 
REFERENCES cust_bill_batch ( billbatchnum )
Schema upgrade completed in 8 seconds
Application pruning completed in 0 seconds
Re-initialization with updated schema completed in 5 seconds
Custom fields data upgrade completed at /usr/bin/freeside-upgrade line 401.
Use of uninitialized value $total_new_charges in numeric gt (>) at 
/usr/share/perl5/FS/Upgrade.pm line 152.
Use of uninitialized value in pattern match (m//) at 
/usr/share/perl5/FS/Upgrade.pm line 173.
Use of uninitialized value $agentnum in join or string at 
/usr/share/perl5/FS/Conf.pm line 362.
Use of uninitialized value in join or string at 
/usr/share/perl5/FS/Conf.pm line 362.
Config updates completed in 0 seconds
Upgrading part_event_condition...
   committing
   done in 0 seconds
Upgrading part_event...
   committing
   done in 0 seconds
Upgrading cust_main...
DBD::Pg::st execute failed: ERROR:  duplicate key value violates unique 
constraint "cust_location_pkey"
DETAIL:  Key (locationnum)=(6) already exists. [for Statement "INSERT 
INTO cust_location ( locationnum, custnum, address1, city, state, zip, 
latitude, longitude, coord_auto, country) VALUES ('6', '5', '145 noway 
', 'Dallas', 'CA', '78945', '43.0119437', '-84.7411244', 'Y', 'US')"] at 
/usr/share/perl5/FS/Record.pm line 1376.
Error upgradging payment information for custnum 5: ERROR: duplicate key 
value violates unique constraint "cust_location_pkey"
DETAIL:  Key (locationnum)=(6) already exists. at 
/usr/share/perl5/FS/cust_main.pm line 5720.


On 10/12/2016 3:48 PM, Ian Fraser wrote:
> Thanks for the tips....
>
> The rt portion of the upgrade completed     sudo su -l freeside -c 
> '/opt/rt3/sbin/rt-setup-database --dba freeside 
> --prompt-for-dba-password --action upgrade'   without any errors
>
> And a dry run on the Freeside upgrade
>
> sudo su -l freeside -c '/usr/bin/freeside-upgrade -r -d fs_daily'
>
> appears to complete fine but when I try to actually implement the 
> upgrade it dies as below.
>
> guest at freeside4:/opt/rt3$ sudo su -l freeside -c 
> '/usr/bin/freeside-upgrade -r fs_daily'
> \Subroutine JSON::XS::Boolean::(-- redefined at 
> /usr/share/perl/5.20/overload.pm line 50.
> Subroutine JSON::XS::Boolean::(++ redefined at 
> /usr/share/perl/5.20/overload.pm line 50.
> Subroutine JSON::XS::Boolean::(0+ redefined at 
> /usr/share/perl/5.20/overload.pm line 50.
> FS::part_event::Condition::payby is disabled; skipping
> Upgrade startup completed in 3 seconds
> UPDATE cust_main SET agent_custid = NULL where agent_custid = ''
> UPDATE h_cust_main SET agent_custid = NULL where agent_custid = ''
>
>       SELECT SETVAL( 'upgrade_journal_upgradenum_seq',
>                      ( SELECT MAX(upgradenum) FROM upgrade_journal )
>                    )
>
> Upgrading cust_bill_pkg_detail schema...
>   committing
>   done in 0 seconds
> Upgrading TicketSystem schema...
>   committing
>   done in 0 seconds
> Upgrading password_history schema...
> Can't call method "columns" on an undefined value at 
> /usr/share/perl5/FS/password_history.pm line 166.
>
> sub _upgrade_schema {
>   # clean up history records where linked_acct has gone away
>   my @where;
>   for my $fk ( grep /__/, __PACKAGE__->dbdef_table->columns ) 
> {                 <--- upgrade dies here
>     my ($table, $key) = split(/__/, $fk);
>     push @where, "
>       ( $fk IS NOT NULL AND NOT EXISTS(SELECT 1 FROM $table WHERE 
> $table.$key = $fk) )";
>   }
>   my @recs = qsearch({
>       'table'     => 'password_history',
>       'extra_sql' => ' WHERE ' . join(' AND ', @where),
>   });
>   my $error;
>   if (@recs) {
>     warn "Removing unattached password_history records 
> (".scalar(@recs).").\n";
>     foreach my $password_history (@recs) {
>       $error = $password_history->delete;
>       die $error if $error;
>     }
>   }
>   '';
>
>
>
>> On 06/12/2016 1:22 AM, Erreu Gedmon wrote:
>>> I haven't tested it, but you could try something like this:
>>>
>>> su -l freeside -c '/usr/bin/freeside-backup fs_daily' # create a backup, copy it to the 4.1 system
>>>
>>> /etc/init.d/freeside stop ; pkill -f freeside ; systemctl stop apache2 ; systemsctl restart postgres # stop the 4.1 system
>>> createdb -E UTF8 freeside' # create the database if it doesn't exist (I can't recall if this step is necessary)
>>> su -l freeside -c 'pg_restore --dbname freeside -Fc freeside_backup.Pg' # restore the database
>>> su -l freeside -c "freeside-upgrade fs_daily" # upgrade the 3.6 data to 4.1
>>> /etc/init.d/freeside restart
>>>
>>> Erreu Gedmon
>>>
>>> --
>>> "You see persons and things not as they are but as you are."
>>>          -- Anthony De Mello
>>>
>>> On 12/05/2016 03:22 PM, Ian Fraser wrote:
>>>> I have a production 3.6git  instance of Freeside.  'Upgrading' a mirrored development copy has not gone well.
>>>>
>>>>
>>>> Is it possible to import a 3.6 db into a clean 4.1 install or a 4.1 VMWare image ?
>>>>
>>>>
>>>> Thanks,
>>>> Ian
>>>> _______________________________________________
>>>> freeside-users mailing list
>>>> freeside-users at freeside.biz
>>>> http://freeside.biz/cgi-bin/mailman/listinfo/freeside-users
>>> _______________________________________________
>>> freeside-users mailing list
>>> freeside-users at freeside.biz
>>> http://freeside.biz/cgi-bin/mailman/listinfo/freeside-users
>>
>> -- 
>> Ian Fraser
>> goZoom.ca Inc.
>> 195 Libby's Rd. McNab-Braeside
>> K7S0E1
>> 877(613) 622 0093 ext 21
>
> -- 
> Ian Fraser
> goZoom.ca Inc.
> 195 Libby's Rd. McNab-Braeside
> K7S0E1
> 877(613) 622 0093 ext 21
>
>
> _______________________________________________
> freeside-users mailing list
> freeside-users at freeside.biz
> http://freeside.biz/cgi-bin/mailman/listinfo/freeside-users

-- 
Ian Fraser
goZoom.ca Inc.
195 Libby's Rd. McNab-Braeside
K7S0E1
877(613) 622 0093 ext 21

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://freeside.biz/pipermail/freeside-users/attachments/20161210/93a670ad/attachment-0001.html>


More information about the freeside-users mailing list