diff options
| author | Xe Iaso <me@christine.website> | 2022-07-10 20:29:07 +0000 |
|---|---|---|
| committer | Xe Iaso <me@christine.website> | 2022-07-10 20:29:07 +0000 |
| commit | 55bf7e4cb403566d7172ef69b8f2f7393ac8627d (patch) | |
| tree | 7b3682e19c97672245cbb97e6c1d1069e812fd8b /src/migrate | |
| parent | b32f5a25afb7b9901476164663c1b7099dcec7a8 (diff) | |
| download | xesite-55bf7e4cb403566d7172ef69b8f2f7393ac8627d.tar.xz xesite-55bf7e4cb403566d7172ef69b8f2f7393ac8627d.zip | |
basic notes support
Signed-off-by: Xe Iaso <me@christine.website>
Diffstat (limited to 'src/migrate')
| -rw-r--r-- | src/migrate/base_schema.sql | 11 | ||||
| -rw-r--r-- | src/migrate/mod.rs | 16 |
2 files changed, 27 insertions, 0 deletions
diff --git a/src/migrate/base_schema.sql b/src/migrate/base_schema.sql new file mode 100644 index 0000000..65d19d0 --- /dev/null +++ b/src/migrate/base_schema.sql @@ -0,0 +1,11 @@ +CREATE TABLE IF NOT EXISTS notes + ( id INTEGER PRIMARY KEY + , content TEXT NOT NULL + , content_html TEXT NOT NULL + , created_at TEXT NOT NULL -- Unix epoch timestamp + , updated_at TEXT -- Unix epoch timestamp + , deleted_at TEXT -- Unix epoch timestamp + , reply_to TEXT + ); + +CREATE INDEX IF NOT EXISTS notes_reply_to ON notes(reply_to); diff --git a/src/migrate/mod.rs b/src/migrate/mod.rs new file mode 100644 index 0000000..a2eb9c3 --- /dev/null +++ b/src/migrate/mod.rs @@ -0,0 +1,16 @@ +use super::establish_connection; +use color_eyre::eyre::Result; +use rusqlite_migration::{Migrations, M}; + +#[instrument(err)] +pub fn run() -> Result<()> { + info!("running"); + let mut conn = establish_connection()?; + + let migrations = Migrations::new(vec![M::up(include_str!("./base_schema.sql"))]); + conn.pragma_update(None, "journal_mode", &"WAL").unwrap(); + + migrations.to_latest(&mut conn)?; + + Ok(()) +} |
