From 83972171d712c60ddfaeb4a68ef1cfd8c314fc10 Mon Sep 17 00:00:00 2001 From: Miquel Sabaté Solà Date: Tue, 12 Aug 2025 09:28:42 +0200 Subject: Ensure a non-NULL value for words.succeeded MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Miquel Sabaté Solà --- lib/mihi/src/lib.rs | 7 ++++--- lib/mihi/src/migrate.rs | 4 ++-- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/lib/mihi/src/lib.rs b/lib/mihi/src/lib.rs index 12953c3..41a9953 100644 --- a/lib/mihi/src/lib.rs +++ b/lib/mihi/src/lib.rs @@ -397,9 +397,9 @@ pub fn create_word(word: Word) -> Result<(), String> { match conn.execute( "INSERT INTO words (enunciated, particle, language_id, declension_id, \ conjugation_id, kind, category, regular, locative, \ - gender, suffix, flags, translation, weight, \ + gender, suffix, flags, translation, weight, succeeded, \ updated_at, created_at) \ - VALUES (?1, ?2, ?3, ?4, ?5, ?6, ?7, ?8, ?9, ?10, ?11, ?12, ?13, ?14, \ + VALUES (?1, ?2, ?3, ?4, ?5, ?6, ?7, ?8, ?9, ?10, ?11, ?12, ?13, ?14, ?15, \ datetime('now'), datetime('now'))", params![ word.enunciated, @@ -415,7 +415,8 @@ pub fn create_word(word: Word) -> Result<(), String> { word.suffix, serde_json::to_string(&word.flags).unwrap(), serde_json::to_string(&word.translation).unwrap(), - word.weight + word.weight, + 0 ], ) { Ok(_) => Ok(()), diff --git a/lib/mihi/src/migrate.rs b/lib/mihi/src/migrate.rs index f8fcc8d..58a1681 100644 --- a/lib/mihi/src/migrate.rs +++ b/lib/mihi/src/migrate.rs @@ -26,8 +26,8 @@ CREATE TABLE IF NOT EXISTS "words" ( "created_at" datetime(6) NOT NULL, "updated_at" datetime(6) NOT NULL, "suffix" varchar, - "language_id" integer, - "succeeded" integer, + "language_id" integer NOT NULL, + "succeeded" integer DEFAULT 0 NOT NULL, "steps" integer DEFAULT 0 NOT NULL, "translation" jsonb DEFAULT '{}', "pending" boolean DEFAULT 0, -- cgit v1.2.3