26 lines
804 B
MySQL
26 lines
804 B
MySQL
|
/* Copyright 2024 (c) Anna Schumaker */
|
||
|
|
||
|
PRAGMA user_version = 3;
|
||
|
|
||
|
/*
|
||
|
* The `listenbrainz_queue` table is used to store recently played tracks
|
||
|
* before submitting them to ListenBrainz. This gives us some form of offline
|
||
|
* recovery, since anything in this table needs to be submitted the next time
|
||
|
* we can successfully connect. As a bonus, I prepopulate this table using
|
||
|
* the last played data from tracks that have already been played when this
|
||
|
* table is created.
|
||
|
*/
|
||
|
|
||
|
CREATE TABLE listenbrainz_queue (
|
||
|
listenid INTEGER PRIMARY KEY,
|
||
|
trackid INTEGER REFERENCES tracks (trackid)
|
||
|
ON DELETE CASCADE
|
||
|
ON UPDATE CASCADE,
|
||
|
timestamp TIMESTAMP DEFAULT CURRENT_TIMESTAMP
|
||
|
);
|
||
|
|
||
|
|
||
|
INSERT INTO listenbrainz_queue (trackid, timestamp)
|
||
|
SELECT trackid, lastplayed FROM tracks
|
||
|
WHERE lastplayed IS NOT NULL;
|