Julio Biason
2 years ago
8 changed files with 73 additions and 2 deletions
@ -0,0 +1,23 @@
|
||||
CREATE TABLE IF NOT EXISTS entry ( |
||||
id TEXT PRIMARY KEY, |
||||
title TEXT, |
||||
content TEXT, |
||||
source TEXT |
||||
); |
||||
|
||||
CREATE TABLE IF NOT EXISTS meta ( |
||||
id TEXT PRIMARY KEY, |
||||
entry TEXT REFERENCES entry (id) |
||||
ON DELETE CASCADE, |
||||
name VARCHAR(255), |
||||
value VARCHAR(255) |
||||
); |
||||
|
||||
CREATE TABLE IF NOT EXISTS attachment ( |
||||
id TEXT PRIMARY KEY, |
||||
entry TEXT REFERENCES entry (id) |
||||
ON DELETE CASCADE, |
||||
name VARCHAR(100), |
||||
content_type VARCHAR(100), |
||||
content TEXT |
||||
); |
@ -0,0 +1,15 @@
|
||||
//! Options for running the Store server.
|
||||
|
||||
use std::path::PathBuf; |
||||
|
||||
use clap::Parser; |
||||
|
||||
#[derive(Parser)] |
||||
#[command(author, version, long_about, color = clap::ColorChoice::Always)] |
||||
/// Store is the central part of the Memoirs. It keeps all the data from
|
||||
/// the several Capturers and offers searches for the Viewers.
|
||||
pub struct Options { |
||||
/// Working directory
|
||||
#[arg(short, long, env = "STORE_PATH", default_value = "./")] |
||||
pub working_directory: PathBuf, |
||||
} |
@ -0,0 +1,24 @@
|
||||
use clap::Parser; |
||||
use sqlx::sqlite::SqliteConnectOptions; |
||||
use sqlx::sqlite::SqlitePoolOptions; |
||||
|
||||
use crate::domain::options::Options; |
||||
|
||||
mod domain; |
||||
|
||||
#[tokio::main] |
||||
async fn main() -> Result<(), sqlx::Error> { |
||||
dotenv::dotenv().ok(); |
||||
let options = Options::parse(); |
||||
|
||||
let pool = SqlitePoolOptions::new() |
||||
.connect_with( |
||||
SqliteConnectOptions::new() |
||||
.filename(options.working_directory.join("memoirs.sqlite")) |
||||
.create_if_missing(true), |
||||
) |
||||
.await?; |
||||
sqlx::migrate!("./migrations").run(&pool).await?; |
||||
print!("Hello world!"); |
||||
Ok(()) |
||||
} |
Loading…
Reference in new issue