.system ls -1 /dev/tty[AGU]*;lsusb
.open 'ramdisk/aiox.db'
PRAGMA busy_timeout=6000;

.read cr_tables.sql
.read cr_ids.sql
.read cr_views.sql

--reload ramdisk database from ssd
attach 'aiox.db' as ssd;
.databases
.tables

.echo on
begin transaction;
-- John keeps last 3 days in ramdisk
-- Chuck keeps last 8 days
select date(max(dt), '-8 days') from ssd.irx ;
insert or ignore into irx  select * from ssd.irx where dt >  (select date(max(dt), '-8 days') from ssd.irx) ;
insert or ignore into ir   select * from ssd.ir  where dt >  (select date(max(dt), '-8 days') from ssd.ir) ;
insert or ignore into hrx  select * from ssd.hrx where dt >  (select date(max(dt), '-8 days') from ssd.hrx) ;
insert or ignore into hr   select * from ssd.hr  where dt >  (select date(max(dt), '-8 days') from ssd.hr) ;
end transaction;

