add: journals base

add: avatar/banner upload endpoints
This commit is contained in:
trisua 2025-03-23 18:03:11 -04:00
parent b3cac5f97a
commit bb682add85
14 changed files with 323 additions and 22 deletions

View file

@ -1 +1,2 @@
pub const CREATE_TABLE_USERS: &str = include_str!("./sql/create_users.sql");
pub const CREATE_TABLE_PAGES: &str = include_str!("./sql/create_pages.sql");

View file

@ -34,17 +34,9 @@ impl DataManager {
},
NoTls,
);
let pool = Pool::builder().max_size(15).build(manager).await.unwrap();
let this = Self(config.clone(), read_langs(), pool);
let c = this.clone();
let conn = c.connect().await?;
conn.execute(super::common::CREATE_TABLE_USERS, &[])
.await
.unwrap();
Ok(this)
Ok(Self(config.clone(), read_langs(), pool))
}
}

View file

@ -0,0 +1,9 @@
CREATE TABLE IF NOT EXISTS pages (
id INTEGER NOT NULL PRIMARY KEY,
created INTEGER NOT NULL,
title TEXT NOT NULL,
prompt TEXT NOT NULL,
owner TEXT NOT NULL,
read_access TEXT NOT NULL,
write_access TEXT NOT NULL
)

View file

@ -15,10 +15,9 @@ impl DataManager {
/// Create a new [`DataManager`] (and init database).
pub async fn new(config: Config) -> Result<Self> {
let this = Self(config.clone(), read_langs());
let conn = this.connect().await?;
let conn = this.connect().await?;
conn.pragma_update(None, "journal_mode", "WAL").unwrap();
conn.execute(super::common::CREATE_TABLE_USERS, ()).unwrap();
Ok(this)
}