Coverage for downtify/db/migrations/versions/0002_download_sources.py: 100%

6 statements  

« prev     ^ index     » next       coverage.py v7.17.4, created at 2026-11-21 22:18 +0000

1"""Each file's upload and the uploads rejected per song (issue #582). 

2 

3Mirrors :class:`downtify.download_sources.DownloadSources`. 

4""" 

5 

6from __future__ import annotations 

7 

8from downtify.db.core import Connection 

9 

10DDL: list[str] = [ 

11 """ 

12 CREATE TABLE IF NOT EXISTS file_download_sources ( 

13 file TEXT PRIMARY KEY, 

14 source TEXT NOT NULL DEFAULT '', 

15 track_keys TEXT NOT NULL DEFAULT '[]', 

16 signature TEXT NOT NULL DEFAULT '', 

17 recorded_at DOUBLE PRECISION NOT NULL 

18 ) 

19 """, 

20 """ 

21 CREATE TABLE IF NOT EXISTS rejected_sources ( 

22 track_key TEXT NOT NULL, 

23 source TEXT NOT NULL, 

24 rejected_at DOUBLE PRECISION NOT NULL, 

25 PRIMARY KEY (track_key, source) 

26 ) 

27 """, 

28] 

29 

30 

31def up(conn: Connection) -> None: 

32 for stmt in DDL: 

33 conn.execute(stmt)