Add "IF NOT EXISTS" to create query

This commit is contained in:
Mateusz Słodkowicz 2024-03-18 14:54:24 +01:00
parent 665fc7c6a7
commit 011f3ab497
Signed by: materus
GPG Key ID: 28D140BCA60B4FD1
1 changed files with 4 additions and 4 deletions

View File

@ -192,7 +192,7 @@ pub fn create_cache() -> Result<()> {
conn.execute( conn.execute(
" "
CREATE TABLE config ( CREATE TABLE IF NOT EXISTS config (
name TEXT PRIMARY KEY, name TEXT PRIMARY KEY,
value TEXT NOT NULL value TEXT NOT NULL
)", )",
@ -201,7 +201,7 @@ pub fn create_cache() -> Result<()> {
conn.execute( conn.execute(
" "
CREATE TABLE currencies ( CREATE TABLE IF NOT EXISTS currencies (
code TEXT PRIMARY KEY, code TEXT PRIMARY KEY,
text TEXT NOT NULL, text TEXT NOT NULL,
next_update TIME NOT NULL next_update TIME NOT NULL
@ -211,7 +211,7 @@ pub fn create_cache() -> Result<()> {
conn.execute( conn.execute(
" "
CREATE TABLE exchange_rates ( CREATE TABLE IF NOT EXISTS exchange_rates (
code_from TEXT NOT NULL, code_from TEXT NOT NULL,
code_to TEXT NOT NULL, code_to TEXT NOT NULL,
rate TEXT NOT NULL, rate TEXT NOT NULL,
@ -222,7 +222,7 @@ pub fn create_cache() -> Result<()> {
conn.execute( conn.execute(
" "
INSERT INTO config (name, value) VALUES ( INSERT OR IGNORE INTO config (name, value) VALUES (
'API_KEY', 'API_KEY',
'' ''
) )