create table jin_payplan
(
  id                      int(11) not null primary key,

  prod_id                 int(11) not null default 0,
  title                   varchar(255) not null default '',

  is_flat                 int(1) not null default 0,

  amount                  varchar(15) not null default '',

  period_l                varchar(10) not null default '',
  period_u                char(1) not null default '',
  numinst                 varchar(10) not null default '',
  
  trial_l                 varchar(10) not null default '',
  trial_u                 char(1) not null default '',
  trial_amount            varchar(15) not null default '',

  shipping                int(1) not null default 0,

  key(prod_id)
);


alter table jin_product add payplan_id int(11) not null default 0 after cost;
create index payplan_id on jin_product(payplan_id);

alter table jin_oto change links_style buttons_style varchar(30) not null default '' after descr;
alter table jin_oto change paylink_title yesbtn_title varchar(255) not null default '' after buttons_style;
alter table jin_oto add yesbtn_attr varchar(255) not null default '' after yesbtn_title;
alter table jin_oto change next_oto_link_title nobtn_title varchar(255) not null default '' after yesbtn_attr;
alter table jin_oto add nobtn_attr varchar(255) not null default '' after nobtn_title;
alter table jin_oto add dest_prod_id int(11) not null default 0 after nobtn_attr;
alter table jin_oto change paylink_url dest_url varchar(255) not null default '' after dest_prod_id;

alter table jin_order add is_bulk int(1) not null default 0 after complete;
update jin_order, jin_package set jin_order.is_bulk=1 where jin_order.pack_id=jin_package.id and jin_package.pgates!='' and jin_package.type!=5;

alter table jin_package add combo_ty int(1) not null default 0;

alter table jin_order add aweber_done int(1) not null default 0 after is_bulk;
update jin_order set aweber_done=1;
alter table jin_sale drop aweber_done;

alter table jin_package change autoresp_ids sale_autoresp_ids varchar(255) not null default '';
alter table jin_package add squeeze_autoresp_ids varchar(255) not null default '' after locked_ext;

alter table jin_package add hide_prodlist int(1) not null default 0 after currency_rate;

alter table jin_theme add custom_s1 varchar(30) not null default '';
alter table jin_theme add custom_v1 varchar(255) not null default '';
alter table jin_theme add custom_v2 varchar(255) not null default '';

alter table jin_theme_compiled add custom_packed text not null default '' after template_comp;

alter table jin_payplan add pgates varchar(255) not null default '';

alter table jin_affprog add comm_recur_stop int(3) not null default 0;
alter table jin_affprog add period_guarantee int(11) not null default 0;
alter table jin_affprog add period_guarantee_no4recur int(1) not null default 0;
alter table jin_affprog add aff_instcomm_on int(1) not null default 0;
alter table jin_affprog add aff_instcomm_percent int(3) not null default 0;
alter table jin_affprog add aff_instcomm_order int(1) not null default 0;
alter table jin_affprog add aff_instcomm_tstamp datetime null;

update jin_download set title=url where title='';

alter table jin_affprog add adaptcomm int(1) not null default 0;

alter table jin_invitation add final_html text not null default '';
alter table jin_user_affprog add comment varchar(255) not null default '';

alter table jin_user add paypal_adaptpay_link varchar(255) not null default '';