Merge pull request 'inteligentsql' (#10) from inteligentsql into main

Reviewed-on: #10
This commit is contained in:
Elias Schriefer 2021-09-27 16:52:07 +02:00
commit b8a12fcd42
7 changed files with 22 additions and 13 deletions

View File

@ -1,6 +1,6 @@
-- external_servers_preferences definition
CREATE TABLE external_servers_preferences (
CREATE TABLE IF NOT EXISTS external_servers_preferences (
id TEXT NOT NULL PRIMARY KEY,
external_servers BLOB NOT NULL,
external_servers_limit TEXT NOT NULL,

View File

@ -1,6 +1,6 @@
-- external_servers_privacy_preferences definition
CREATE TABLE external_servers_privacy_preferences (
CREATE TABLE IF NOT EXISTS external_servers_privacy_preferences (
id TEXT NOT NULL PRIMARY KEY,
discovery BLOB NOT NULL,
discovery_user_limit TEXT NOT NULL,

View File

@ -26,3 +26,12 @@ pub async fn load_template(sqlite_handle: &SqlitePool) -> sqlx::Result<SqliteQue
include_str!("external_servers_preferences.sql"),
)).execute(sqlite_handle).await
}
pub async fn add_test_user(sqlite_handle: &mut SqliteConnection)-> sqlx::Result<SqliteQueryResult>{
sqlx::query("insert into users values('1923123','Elierik','erikeli',1,2,3);").execute(sqlite_handle).await
}
pub async fn sqlite_out(sqlite_handle: &mut SqliteConnection, query:&str, index:usize) -> Result<String, sqlx::Error> {
sqlx::query(query).fetch_one(sqlite_handle).await.unwrap().try_get(index)
}

View File

@ -1,6 +1,6 @@
-- notification_preferences definition
CREATE TABLE notification_preferences (
CREATE TABLE IF NOT EXISTS notification_preferences (
id TEXT NOT NULL PRIMARY KEY,
lock_details BOOLEAN DEFAULT 0 NOT NULL CHECK (lock_details IN (0, 1)),
do_not_disturb BOOLEAN DEFAULT 0 NOT NULL CHECK (do_not_disturb IN (0, 1)),

View File

@ -1,6 +1,6 @@
-- privacy_preferences definition
CREATE TABLE privacy_preferences (
CREATE TABLE IF NOT EXISTS privacy_preferences (
id TEXT NOT NULL PRIMARY KEY,
discovery BLOB NOT NULL,
discovery_user_limit TEXT NOT NULL,

View File

@ -1,6 +1,6 @@
-- security_preferences definition
CREATE TABLE "security_preferences" (
CREATE TABLE IF NOT EXISTS "security_preferences" (
id TEXT NOT NULL PRIMARY KEY,
account_tokens TEXT NOT NULL,
password_hash TEXT NOT NULL,

View File

@ -1,6 +1,6 @@
-- users definition
CREATE TABLE users (
CREATE TABLE IF NOT EXISTS users (
id TEXT NOT NULL PRIMARY KEY,
user_name TEXT NOT NULL,
display_name TEXT,