update jin_paylog set type='REQ' where type='PAYPAL_AP_REQ';
update jin_paylog set type='RSP' where type='PAYPAL_AP_RSP';
update jin_paylog set type='IPN' where type='PAYPAL_AP_IPN';
update jin_paylog set type='INTERR' where type='PAYPAL_AP_INTERR';
update jin_paylog set type='IPNERR' where type='PAYPAL_AP_IPNERR';
update jin_paylog set type='APIREFSALE_REQ' where type='APIREFSALE_PAYPAL_AP_REQ';
update jin_paylog set type='APIREFSALE_RSP' where type='APIREFSALE_PAYPAL_AP_RSP';
update jin_paylog set type='APIREFSALE_INTERR' where type='APIREFSALE_PAYPAL_AP_INTERR';
update jin_paylog set type='APISENDPAY_REQ' where type='APISENDPAY_PAYPAL_AP_REQ';
update jin_paylog set type='APISENDPAY_RSP' where type='APISENDPAY_PAYPAL_AP_RSP';
update jin_paylog set type='APISENDPAY_INTERR' where type='APISENDPAY_PAYPAL_AP_INTERR';

update jin_paylog set type='APISALE_REQ' where type='APISALE_PAYFLOW_REQ';
update jin_paylog set type='APISALE_RSP' where type='APISALE_PAYFLOW_RSP';
update jin_paylog set type='APISALE_INTERR' where type='APISALE_PAYFLOW_INTERR';
update jin_paylog set type='APIREFSALE_REQ' where type='APIREFSALE_PAYFLOW_REQ';
update jin_paylog set type='APIREFSALE_RSP' where type='APIREFSALE_PAYFLOW_RSP';
update jin_paylog set type='APIREFSALE_INTERR' where type='APIREFSALE_PAYFLOW_INTERR';
update jin_paylog set type='APIREFSALE_ERROR' where type='APIREFSALE_PAYFLOW_ERROR';
update jin_paylog set type='APIREFUND_REQ' where type='APIREFUND_PAYFLOW_REQ';
update jin_paylog set type='APIREFUND_RSP' where type='APIREFUND_PAYFLOW_RSP';
update jin_paylog set type='APIREFUND_INTERR' where type='APIREFUND_PAYFLOW_INTERR';
update jin_paylog set type='APIREFUND_ERROR' where type='APIREFUND_PAYFLOW_ERROR';

update jin_paylog set type='APISALE_REQ' where type='APISALE_WPPDP_REQ';
update jin_paylog set type='APISALE_RSP' where type='APISALE_WPPDP_RSP';
update jin_paylog set type='APISALE_INTERR' where type='APISALE_WPPDP_INTERR';
update jin_paylog set type='APIREFSALE_REQ' where type='APIREFSALE_WPPDP_REQ';
update jin_paylog set type='APIREFSALE_RSP' where type='APIREFSALE_WPPDP_RSP';
update jin_paylog set type='APIREFSALE_INTERR' where type='APIREFSALE_WPPDP_INTERR';
update jin_paylog set type='APIREFSALE_ERROR' where type='APIREFSALE_WPPDP_ERROR';
update jin_paylog set type='APIREFSALE_VERIFY_REQ' where type='APIREFSALE_WPPDP_VERIFY_REQ';
update jin_paylog set type='APIREFSALE_VERIFY_RSP' where type='APIREFSALE_WPPDP_VERIFY_RSP';
update jin_paylog set type='APIREFSALE_VERIFY_INTERR' where type='APIREFSALE_WPPDP_VERIFY_INTERR';
update jin_paylog set type='APIREFUND_REQ' where type='APIREFUND_WPPDP_REQ';
update jin_paylog set type='APIREFUND_RSP' where type='APIREFUND_WPPDP_RSP';
update jin_paylog set type='APIREFUND_INTERR' where type='APIREFUND_WPPDP_INTERR';
update jin_paylog set type='APIREFUND_ERROR' where type='APIREFUND_WPPDP_ERROR';

alter table jin_jvmsub add cancelreason varchar(255) not null default '' after canceldate;

alter table jin_survey add intro_html text not null default '' after user_acl;

create table jin_texts
(
  id     int(11) not null primary key auto_increment,
  data   text not null default ''
);

alter table jin_survey_question add intro_html int(11) not null default 0;
alter table jin_survey add password varchar(50) not null default '' after return_html;

alter table jin_ccs add id int(11) not null primary key auto_increment after user_id;
alter table jin_sale add ccs_id int(11) not null default 0 after txn_return_url;
create index ccs_id on jin_sale(ccs_id);

alter table jin_jvmsub add refsale_next_ref_id varchar(32) not null default '';

alter table jin_role add priv_member_account_ccupdate varchar(50) not null default '' after priv_member_account_jvmsubs;
update jin_role set priv_member_account_ccupdate=1;

alter table jin_jvmsub add title varchar(255) not null default '' after id;
update jin_jvmsub,jin_sale,jin_product set jin_jvmsub.title=jin_product.title where jin_jvmsub.init_sale_id=jin_sale.id and jin_sale.prod_id=jin_product.id and jin_jvmsub.title='';

alter table jin_jvmsub add refsale_failure_tstamp datetime null;
alter table jin_jvmsub add refsale_failure_reason varchar(255) not null default '';

alter table jin_merchant_settings add refsale_autocancel_period int(3) not null default 0;
alter table jin_merchant_settings add ccupdate_request_intervals varchar(30) not null default '';
alter table jin_merchant_settings add ccupdate_notify_admins varchar(50) not null default '';
update jin_merchant_settings set refsale_autocancel_period = '30';
update jin_merchant_settings set ccupdate_request_intervals = '3,-15,-10,-5,-1';

delete from zen_id_dbtable;
set @max_emaildlv_id = (select if(max(id) is null,0,max(id)) from jin_emaildlv);
insert into jin_emaildlv set id=@max_emaildlv_id+1, anchor_code='ccupdate_req_cust_expire.merchantset.1', disabled=1;
insert into jin_emaildlv set id=@max_emaildlv_id+2, anchor_code='ccupdate_req_cust_failure.merchantset.1', disabled=1;

create index user_id on jin_funnel_visit(user_id);
