update jin_skin_compiled set tmpl_code=concat(tmpl_code,'.html') where tmpl_code not in ('headfoot/css_supl','headfoot/css_chrome');
update jin_skin_compiled set tmpl_code=concat(tmpl_code,'.css') where tmpl_code in ('headfoot/css_supl','headfoot/css_chrome');
update jin_skin_customized set tmpl_code=concat(tmpl_code,'.html') where tmpl_code not in ('headfoot/css_supl','headfoot/css_chrome');
update jin_skin_customized set tmpl_code=concat(tmpl_code,'.css') where tmpl_code in ('headfoot/css_supl','headfoot/css_chrome');

alter table jin_skin_customized add orig_theme varchar(20) not null default '';
alter table jin_skin_customized drop id;


alter table jin_skin_compiled drop skin_file_mtime;
alter table jin_skin_compiled change skin_file real_theme varchar(50) not null default '';

create table jin_theme_meta
(
  tmpl_type       varchar(15) not null default '',
  theme           varchar(20) not null default '',

  title           varchar(255) not null default '',
  
  unique key(tmpl_type,theme)
);

rename table jin_skin_customized to jin_theme;
rename table jin_skin_compiled to jin_theme_compiled;

alter table jin_theme change scope theme varchar(20) not null default '';
alter table jin_theme_compiled change scope theme varchar(20) not null default '';
update jin_theme_compiled set real_theme=substring_index(substring_index(real_theme,'/',2),'/',-1) where real_theme!='';
update jin_theme_compiled set theme=real_theme where theme='global';
update jin_theme_compiled set real_theme='' where real_theme=theme;

alter table jin_merchant_settings add first_login_url varchar(255) not null default '' after reg_cfm_url;

update jin_coupon set otc_all=1 where oct_existing=1;
