From ed35ef6e499d765c5645c69e2c44e51c1ba22d87 Mon Sep 17 00:00:00 2001 From: lifegpc Date: Sun, 18 Sep 2022 13:12:43 +0000 Subject: [PATCH] add is_admin --- doc/db/users.md | 1 + src/db/sqlite/db.rs | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/doc/db/users.md b/doc/db/users.md index 228a1ab..7e915eb 100644 --- a/doc/db/users.md +++ b/doc/db/users.md @@ -4,3 +4,4 @@ | name | Name of user | string | | username | Username of user (unique) | string | | password | Password of user | string | +| is_admin | Whether user is admin | boolean | diff --git a/src/db/sqlite/db.rs b/src/db/sqlite/db.rs index 059b596..3de3702 100644 --- a/src/db/sqlite/db.rs +++ b/src/db/sqlite/db.rs @@ -63,6 +63,7 @@ id INT, name TEXT, username TEXT, password TEXT, +is_admin BOOLEAN, PRIMARY KEY (id) );"; const VERSION_TABLE: &'static str = "CREATE TABLE version ( @@ -73,7 +74,7 @@ v3 INT, v4 INT, PRIMARY KEY (id) );"; -const VERSION: [u8; 4] = [1, 0, 0, 1]; +const VERSION: [u8; 4] = [1, 0, 0, 2]; pub struct PixivDownloaderSqlite { db: Mutex, @@ -105,6 +106,9 @@ impl PixivDownloaderSqlite { tx.execute(TOKEN_TABLE, [])?; tx.execute(USERS_TABLE, [])?; } + if db_version < [1, 0, 0, 2] { + tx.execute("ALTER TABLE users ADD is_admin BOOLEAN;", [])?; + } self._write_version(&tx)?; tx.commit()?; }