
alter table jin_user add admin_notes text not null default '' after help_url_helpdesk;
alter table jin_sale add admin_notes text not null default '' after points_earned;

alter table jin_role add priv_master_customers_actsubs int(1) not null default 0 after priv_master_customers_orders;

alter table jin_role add priv_master_tools_extscripts int(1) not null default 0 after priv_master_tools_apiuser;

create table jin_ext_script
(
  id            int(11) not null primary key,
  owner_id      int(11) not null,
  
  url           varchar(255) not null,
  plugin        varchar(50) not null,
  cfgtext       text not null default '',

  email_create  text not null default '',
  email_delete  text not null default '',
  
  key(owner_id)
);

alter table jin_role add ext_script int(11) not null default 0 after limit_massmailperiod;
alter table jin_user_role add ext_script int(11) not null default 0 after notapproved;

rename table jin_lmem to jin_user_lmem, jin_rmem to jin_user_rmem;

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

  url                 varchar(255) not null default '',
  username            varchar(255) not null default '',
  password            varchar(255) not null default '',

  comment             varchar(255) not null,
  
  key(owner_id)
);

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

  path                varchar(255) not null,

  comment             varchar(255) not null,
  
  key(owner_id)
);

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

  ftp_serv            varchar(255) not null default '',
  ftp_user            varchar(255) not null default '',
  ftp_pass            varchar(255) not null default '',
  ftp_dir             varchar(255) not null default '',
  url                 varchar(255) not null default '',

  comment             varchar(255) not null,
  
  key(owner_id)
);

alter table jin_product add dlv_downloads varchar(255) not null default '' after dlv_link_password;
alter table jin_product add dlv_lmems varchar(255) not null default '' after dlv_lmem_path;
alter table jin_product add dlv_rmems varchar(255) not null default '' after dlv_rmem_url;
alter table jin_product change dlv_link_expire dlv_downloads_expire varchar(50) not null default '';

alter table jin_user_lmem add lmem_id int(11) not null after path;
alter table jin_user_rmem add rmem_id int(11) not null after url;

alter table jin_role add priv_master_store_downloads int(1) not null default 0 after priv_master_store_otos;
alter table jin_role add priv_master_store_lmems int(1) not null default 0 after priv_master_store_downloads;
alter table jin_role add priv_master_store_rmems int(1) not null default 0 after priv_master_store_lmems;

update jin_role set priv_master_store_downloads=1 where priv_master_store_products=1;
update jin_role set priv_master_store_lmems=1 where priv_master_customers_lmems=1;
update jin_role set priv_master_store_rmems=1 where priv_master_customers_rmems=1;

#
#

alter table jin_role add priv_master_tools_export int(1) not null default 0 after priv_master_tools_alerts;

alter table jin_package add aweber_yes int(1) not null default 0 after signature;
alter table jin_package add aweber_url varchar(80) not null default '' after aweber_yes;
alter table jin_package add aweber_data varchar(255) not null default '' after aweber_url;


alter table jin_product add pg_an_recur int(1) not null default 0 after pg_an_txn_key;
alter table jin_product add pg_an_recur_length varchar(10) not null default '' after pg_an_recur;
alter table jin_product add pg_an_recur_unit varchar(10) not null default '' after pg_an_recur_length;
alter table jin_product add pg_an_recur_number varchar(10) not null default '' after pg_an_recur_unit;
alter table jin_product add pg_an_trial_amount varchar(20) not null default '' after pg_an_recur_number;
alter table jin_product add pg_an_trial_number varchar(10) not null default '' after pg_an_trial_amount;

alter table jin_user_settings drop pg_lp_secure_host;
alter table jin_product drop pg_lp_secure_host;
