add is_admin

This commit is contained in:
2022-09-18 13:12:43 +00:00
committed by GitHub
parent 66a5ab9bc4
commit ed35ef6e49
2 changed files with 6 additions and 1 deletions

View File

@@ -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 |

View File

@@ -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<Connection>,
@@ -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()?;
}