move profile filesystem dependencies init on the main level

This commit is contained in:
yggverse 2024-10-02 18:46:08 +03:00
parent b60ac5fb3f
commit e8680cb052
3 changed files with 35 additions and 30 deletions

View file

@ -1,3 +1,4 @@
use sqlite::Connection;
use std::sync::Arc;
pub struct Database {
@ -6,18 +7,18 @@ pub struct Database {
impl Database {
// Construct new application DB
pub fn init(connection: Arc<sqlite::Connection>) -> Database {
pub fn init(connection: Arc<Connection>) -> Database {
// Init app table
if let Err(e) = connection.execute(
if let Err(error) = connection.execute(
r"
CREATE TABLE IF NOT EXISTS `app`
(
`id` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
`time` INTEGER NOT NULL DEFAULT CURRENT_TIMESTAMP,
`time` INTEGER NOT NULL DEFAULT CURRENT_TIMESTAMP
)
",
) {
panic!("{e}");
panic!("{error}");
}
// Return struct