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

  tstamp      datetime null,
  user_id     int(11) not null default 0,

  sqltable    varchar(30) not null default '',
  record_id   int(11) not null default 0,
  sqlfield    varchar(30) not null default '',

  value1      varchar(255) not null default '',
  value2      varchar(255) not null default '',
  
  comment     varchar(255) not null default '',
  
  key(sqltable,sqlfield,record_id)
);

create table jin_sys_alert
(
  tstamp      datetime null,
  expires     datetime null,
  code        varchar(50) not null default '',
  value       varchar(50) not null default '',
  unique key(code)
);

insert into jin_sys_alert select tstamp,date_add(tstamp,interval 30 hour),'cron',1 from jin_cron;

alter table jin_sale add tstamp_date date null after tstamp;
update jin_sale set tstamp_date=date(tstamp);
create index tstamp_date_paid on jin_sale(tstamp_date,paid);

alter table jin_merchant_settings add welcome_screen_on int(1) not null default 0 after api_post_changeuser;
update jin_merchant_settings set welcome_screen_on=1 where length(welcome_screen) >= 80;

alter table jin_merchant_settings add admin_dashboard_on int(1) not null default 0 after welcome_screen;
