# All dates are stored as the number of milliseconds since # 1 January 1970 00:00:00. This is compatible with NSPR and JS playHistotryTableCreate=\ CREATE TABLE play_history_items_v1 ( \ idx integer primary key autoincrement, \ ts integer not null default current_timestamp, \ playlistRef text not null, \ playlistIndex integer not null, \ metadataTitle text, \ metadataArtist text, \ metadataAlbum text, \ metadataUrl text not null, \ metadataUuid text not null, \ metadataLength integer not null, \ startState integer not null, \ startTime integer not null, \ stopState integer not null default 0, \ stopTime integer not null default 0, \ stopPosition integer not null default 0 \ ) playHistotryIdxIndexCreate=\ CREATE INDEX idx_play_history_items_v1_idx ON play_history_items_v1 (idx) playHistotryTsIndexCreate=\ CREATE INDEX idx_play_history_items_v1_ts ON play_history_items_v1 (ts) itemInsert=\ INSERT INTO play_history_items_v1 ( \ ts, \ playlistRef, \ playlistIndex, \ metadataTitle, \ metadataArtist, \ metadataAlbum, \ metadataUrl, \ metadataUuid, \ metadataLength, \ startState, \ startTime, \ stopState, \ stopTime, \ stopPosition \ ) \ VALUES ( \ %S, \ '%S', \ %S, \ '%S', \ '%S', \ '%S', \ '%S', \ '%S', \ %S, \ %S, itemInsert1=\ %S, \ %S, \ %S, \ %S \ ) deleteOldItems=\ DELETE FROM \ play_history_items_v1 \ WHERE \ ts < %S deleteAllItems=\ DELETE FROM \ play_history_items_v1 selectItems=\ SELECT \ idx, \ ts, \ playlistRef, \ playlistIndex, \ metadataTitle, \ metadataArtist, \ metadataAlbum, \ metadataUrl, \ metadataUuid, \ metadataLength, \ startState, \ startTime, \ stopState, \ stopTime, \ stopPosition \ FROM \ play_history_items_v1 \ WHERE \ %S \ ORDER BY \ %S selectMaxIdx=\ SELECT \ max(idx) \ FROM \ play_history_items_v1 selectTsForIdx=\ SELECT \ ts \ FROM \ play_history_items_v1 \ WHERE \ idx = %S