From 011f3ab4976d6f5e5361092c2105ea3f6ac61a16 Mon Sep 17 00:00:00 2001 From: materus Date: Mon, 18 Mar 2024 14:54:24 +0100 Subject: [PATCH] Add "IF NOT EXISTS" to create query --- src/cache.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/cache.rs b/src/cache.rs index 2fd3047..10db9ee 100644 --- a/src/cache.rs +++ b/src/cache.rs @@ -192,7 +192,7 @@ pub fn create_cache() -> Result<()> { conn.execute( " - CREATE TABLE config ( + CREATE TABLE IF NOT EXISTS config ( name TEXT PRIMARY KEY, value TEXT NOT NULL )", @@ -201,7 +201,7 @@ pub fn create_cache() -> Result<()> { conn.execute( " - CREATE TABLE currencies ( + CREATE TABLE IF NOT EXISTS currencies ( code TEXT PRIMARY KEY, text TEXT NOT NULL, next_update TIME NOT NULL @@ -211,7 +211,7 @@ pub fn create_cache() -> Result<()> { conn.execute( " - CREATE TABLE exchange_rates ( + CREATE TABLE IF NOT EXISTS exchange_rates ( code_from TEXT NOT NULL, code_to TEXT NOT NULL, rate TEXT NOT NULL, @@ -222,7 +222,7 @@ pub fn create_cache() -> Result<()> { conn.execute( " - INSERT INTO config (name, value) VALUES ( + INSERT OR IGNORE INTO config (name, value) VALUES ( 'API_KEY', '' )