mirror of
https://github.com/YGGverse/Yoda.git
synced 2026-03-31 16:45:27 +00:00
handle errors, drop version from struct
This commit is contained in:
parent
afd9bc3134
commit
b60ac5fb3f
1 changed files with 13 additions and 20 deletions
|
|
@ -2,33 +2,26 @@ use std::sync::Arc;
|
||||||
|
|
||||||
pub struct Database {
|
pub struct Database {
|
||||||
connection: Arc<sqlite::Connection>,
|
connection: Arc<sqlite::Connection>,
|
||||||
// Autostart migrate feature on app and db versions mismatch
|
|
||||||
version: i32,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Database {
|
impl Database {
|
||||||
// Construct new application DB
|
// Construct new application DB
|
||||||
pub fn init(connection: Arc<sqlite::Connection>) -> Database {
|
pub fn init(connection: Arc<sqlite::Connection>) -> Database {
|
||||||
// Create app table if not exist yet
|
// Init app table
|
||||||
/*
|
if let Err(e) = connection.execute(
|
||||||
connection
|
r"
|
||||||
.execute(
|
CREATE TABLE IF NOT EXISTS `app`
|
||||||
r"
|
(
|
||||||
CREATE TABLE IF NOT EXISTS `app`
|
`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
|
||||||
(
|
`time` INTEGER NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||||
`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
|
)
|
||||||
`time` INTEGER NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
",
|
||||||
`version` VARCHAR NOT NULL
|
) {
|
||||||
)
|
panic!("{e}");
|
||||||
",
|
}
|
||||||
)
|
|
||||||
.unwrap(); // @TODO handle errors */
|
|
||||||
|
|
||||||
// Return struct
|
// Return struct
|
||||||
Self {
|
Self { connection }
|
||||||
connection,
|
|
||||||
version: 1, // @TODO
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Restore previous browser session from DB
|
// Restore previous browser session from DB
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue