alter table jin_merchant_settings add tech_email varchar(255) not null default '' after from_email;

alter table jin_package add abandone_yes int(1) not null default 0 after aweber_settings;
alter table jin_package add abandone_waithours varchar(5) not null default '' after abandone_yes;
alter table jin_package add abandone_email text not null default '' after abandone_waithours;
alter table jin_package add abandone_fum_id int(11) not null default 0 after abandone_email;

create table jin_abandone
(
  tstamp               datetime null,

  pack_id              int(11) not null default 0,
  user_id              int(11) not null default 0,

  primary key(pack_id,user_id)
);

create table jin_cron
(
  id                   int(11) not null primary key,
  tstamp               datetime null
);

replace into jin_cron set id=1,tstamp=now();

alter table jin_role add priv_member_account_backlink varchar(50) not null default '' after priv_member_account_helptickets;

create table jin_backlink
(
  id           int(11) not null primary key,
  
  title        varchar(40) not null default '',
  url          varchar(255) not null default '',
  descr        varchar(150) not null default '',
  image        varchar(255) not null default '',
  
  rating_self  int(11) not null default 0,
  rating       int(11) not null default 0,
  
  last_id      int(11) not null default 0,
  last_ip      varchar(50) not null default '',
  
  key(rating)
);


alter table jin_role add priv_master_users_insignia varchar(50) not null default '' after priv_master_users_approve;

create table jin_insignia_group
(
  id     int(11) not null primary key,
  
  title  varchar(255) not null default ''
);

create table jin_insignia_category
(
  id         int(11) not null primary key,
  
  group_id   int(11) not null default 0,
  
  tstamp     datetime null,
  
  title      varchar(255) not null default '',
  color      varchar(30) not null default '',
  
  fulltitle  varchar(255) not null default '',
  
  key(group_id)
);

alter table jin_product add dlv_insignia varchar(255) not null default '' after dlv_lessonseries;

alter table jin_api_user add u_insignia varchar(255) not null default '' after u_memberships;
alter table jin_supro add u_insignia varchar(255) not null default '' after u_memberships;
alter table jin_specusers add u_insignia varchar(255) not null default '' after u_memberships;

alter table jin_user add adminlink_tstamp datetime null after no_upline_mail;
alter table jin_user add adminlink_html varchar(255) not null default '' after adminlink_tstamp;



alter table jin_massmail_jobitem add from_name varchar(255) not null default '' after user_passwd;
alter table jin_massmail_jobitem add from_email varchar(255) not null default '' after from_name;

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

  title                varchar(255) not null default '',

  user_acl             varchar(255) not null default '',

  return_url           varchar(255) not null default '',
  return_html          text not null default ''
);

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

  survey_id            int(11) not null default 0,

  title                varchar(255) not null default '',
  seq                  int(3) not null default 0,
  required             int(1) not null default 0,
  
  selector_data        text not null default '',
  selector_type        varchar(30) not null default '',

  text_enabled         int(1) not null default 0,
  text_type            varchar(30) not null default '',
  text_caption         varchar(255) not null default '',
  text_is_big          int(1) not null default 0,  

  key(survey_id)
);

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

  tstamp               datetime null,

  survey_id            int(11) not null default 0,
  user_id              int(11) not null default 0,

  key(user_id),
  key(survey_id)
);

create table jin_survey_data_small
(
  data_id              int(11) not null default 0,
  question_id          int(11) not null default 0,

  answer               varchar(255) not null default '',
  
  seq                  int(11) not null default 0,
  
  key(data_id,question_id)
);

create table jin_survey_data_big
(
  data_id              int(11) not null default 0,
  question_id          int(11) not null default 0,

  answer               text not null default '',
  
  seq                  int(11) not null default 0,
  
  key(data_id,question_id)
);

alter table jin_role add priv_master_plugins_surveys varchar(50) not null default '' after priv_master_plugins_lessonman;
alter table jin_role add priv_member_account_surveys varchar(50) not null default '' after priv_member_account_backlink;

alter table jin_api_user add u_surveys varchar(255) not null default '' after u_insignia;
alter table jin_supro add u_surveys varchar(255) not null default '' after u_insignia;
alter table jin_specusers add u_surveys varchar(255) not null default '' after u_insignia;

alter table jin_product add pg_recur varchar(3) not null default '' after pgates;
update jin_product set pg_recur='ext' where pg_recur='' and pg_use_ext_recur!='';
update jin_product set pg_recur='int' where pg_recur='' and pg_use_int_recur!='';

alter table jin_sale add subscr_amount varchar(50) not null default '' after subscr_refsale;
alter table jin_sale add subscr_amount_prod varchar(50) not null default '' after subscr_amount;


alter table jin_user add shipping_address varchar(255) not null default '' after country;
alter table jin_user add shipping_city    varchar(255) not null default '' after shipping_address;
alter table jin_user add shipping_state   varchar(255) not null default '' after shipping_city;
alter table jin_user add shipping_zipcode varchar(255) not null default '' after shipping_state;
alter table jin_user add shipping_country varchar(255) not null default '' after shipping_zipcode;

alter table jin_order add shipping_address varchar(255) not null default '' after user_country;
alter table jin_order add shipping_city    varchar(255) not null default '' after shipping_address;
alter table jin_order add shipping_state   varchar(255) not null default '' after shipping_city;
alter table jin_order add shipping_zipcode varchar(255) not null default '' after shipping_state;
alter table jin_order add shipping_country varchar(255) not null default '' after shipping_zipcode;

alter table jin_product add pg_recur_shipping int(1) not null default 0 after pg_recur_trial_amount;
alter table jin_sale add shipping_recur int(1) not null default 0 after shipping_subid;

create table jin_emaildlv
(
  id                  int(11) not null primary key,
  
  title               varchar(255) not null default '',

  subject             varchar(255) not null default '',
  message             varchar(255) not null default ''
);

alter table jin_funnel_step add emaildlvs varchar(255) not null default '';
