diff options
author | Benedikt Peetz <benedikt.peetz@b-peetz.de> | 2024-08-22 20:32:51 +0200 |
---|---|---|
committer | Benedikt Peetz <benedikt.peetz@b-peetz.de> | 2024-08-22 20:32:51 +0200 |
commit | aded88ac8094a71a8ed559615e4150d302fb5e8b (patch) | |
tree | 655e60efc40cc5d068c1103f2fcac0a6c6904176 /src | |
parent | refactor(storage/getters): Inline an Option re-creation with `map` (diff) | |
download | yt-aded88ac8094a71a8ed559615e4150d302fb5e8b.tar.gz yt-aded88ac8094a71a8ed559615e4150d302fb5e8b.zip |
fix(storage/schema.sql): Tell SQLite to perform type-checking
Otherwise, SQLite tries to “coerce” types into fitting in the “preferred” type of the table. Now SQLite actually refuses to accept a type mismatch.
Diffstat (limited to '')
-rw-r--r-- | src/storage/video_database/schema.sql | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/src/storage/video_database/schema.sql b/src/storage/video_database/schema.sql index b05d908..3afd091 100644 --- a/src/storage/video_database/schema.sql +++ b/src/storage/video_database/schema.sql @@ -8,7 +8,8 @@ -- You should have received a copy of the License along with this program. -- If not, see <https://www.gnu.org/licenses/gpl-3.0.txt>. --- The base schema +-- All tables should be declared STRICT, as I actually like to have types checking (and a +-- db that doesn't lie to me). -- Keep this table in sync with the `Video` structure CREATE TABLE IF NOT EXISTS videos ( @@ -18,7 +19,7 @@ CREATE TABLE IF NOT EXISTS videos ( 1 END), description TEXT, - duration FLOAT, + duration REAL, extractor_hash TEXT UNIQUE NOT NULL PRIMARY KEY, last_status_change INTEGER NOT NULL, parent_subscription_name TEXT, @@ -39,7 +40,7 @@ CREATE TABLE IF NOT EXISTS videos ( thumbnail_url TEXT, title TEXT NOT NULL, url TEXT UNIQUE NOT NULL -); +) STRICT; -- Store additional metadata for the videos marked to be watched CREATE TABLE IF NOT EXISTS video_options ( @@ -47,10 +48,10 @@ CREATE TABLE IF NOT EXISTS video_options ( subtitle_langs TEXT NOT NULL, playback_speed REAL NOT NULL, FOREIGN KEY(extractor_hash) REFERENCES videos (extractor_hash) -); +) STRICT; -- Store subscriptions CREATE TABLE IF NOT EXISTS subscriptions ( name TEXT UNIQUE NOT NULL PRIMARY KEY, url TEXT NOT NULL -); +) STRICT; |