Update Version: 1.4.0

This commit is contained in:
2026-05-14 18:40:27 -04:00
parent 6178e9e55b
commit 7afd726188
21 changed files with 1051 additions and 278 deletions
+12 -1
View File
@@ -11,7 +11,9 @@ pub async fn init_schema(pool: &AnyPool) {
id TEXT PRIMARY KEY,
username TEXT NOT NULL UNIQUE,
email TEXT UNIQUE,
password_hash TEXT NOT NULL
password_hash TEXT NOT NULL,
is_admin INTEGER NOT NULL DEFAULT 0,
created_at TEXT DEFAULT (strftime('%Y-%m-%d %H:%M:%S', 'now'))
)",
"CREATE TABLE IF NOT EXISTS folders (
id TEXT PRIMARY KEY,
@@ -87,4 +89,13 @@ pub async fn init_schema(pool: &AnyPool) {
.await
.expect("Failed to execute SQLite schema");
}
// Idempotent migrations for existing databases
let migrations = [
"ALTER TABLE users ADD COLUMN is_admin INTEGER NOT NULL DEFAULT 0",
"ALTER TABLE users ADD COLUMN created_at TEXT DEFAULT (strftime('%Y-%m-%d %H:%M:%S', 'now'))",
];
for stmt in &migrations {
let _ = sqlx::query(stmt).execute(pool).await;
}
}