sonda/migrations/postgres/0031_outside_plays.sql
tgiachi 3ba087bcc5 feat(import): keep the artist and the time of plays of artists I do not have
The plays of songs that are not in the library were only counted. Now, when
such a play counts as listened (not a skip, long enough), its artist and its
time are kept in a new table (migration 0031, outside_plays), so a model can
later learn which artists are played together, also those not in the library.
No title, album, IP address, country or platform is stored. The same play is
kept once however many times the export is imported, and the report says how
many were kept (history.kept_outside).
2026-11-15 10:50:29 +01:00

12 lines
431 B
SQL

-- PostgreSQL flavour of sqlite/0031_outside_plays.sql.
CREATE TABLE outside_plays (
user_id BIGINT NOT NULL REFERENCES users(id) ON DELETE CASCADE,
idempotency_key TEXT NOT NULL,
artist TEXT NOT NULL,
artist_key TEXT NOT NULL,
played_at BIGINT NOT NULL,
PRIMARY KEY (user_id, idempotency_key)
);
CREATE INDEX idx_outside_plays_time ON outside_plays(user_id, played_at);