add hidden date field for sorting posts

This commit is contained in:
2022-09-07 18:22:29 -06:00
parent 9a6b49a71b
commit 7f61bd7bdc
3 changed files with 8 additions and 6 deletions

View File

@@ -29,7 +29,7 @@ module Q = struct
content text NOT NULL, content text NOT NULL,
date text NOT NULL, date text NOT NULL,
active TINYINT DEFAULT 1, active TINYINT DEFAULT 1,
hidden_date DEFAULT (unixepoch('now')) hidden_date timestamp DEFAULT (strftime('%s', 'now')))
|eos} |eos}
let create_blog_post = let create_blog_post =

View File

@@ -6,7 +6,7 @@
"@opam/caqti": "*", "@opam/caqti": "*",
"@opam/lwt_ppx": "*", "@opam/lwt_ppx": "*",
"@opam/caqti-driver-sqlite3": "*", "@opam/caqti-driver-sqlite3": "*",
"ocaml": "4.12.x" "ocaml": "*"
}, },
"scripts": { "scripts": {

View File

@@ -2,12 +2,14 @@ open Lwt.Infix
open Database open Database
open Render open Render
exception DatabaseCreationFailure let db_created = ref true
let _ = let _ = Database.create_blog_post_table () >>= function
Database.create_blog_post_table () >>= function
| Ok () -> Lwt_io.print "Database initialized successfully.\n" | Ok () -> Lwt_io.print "Database initialized successfully.\n"
| Error _ -> raise DatabaseCreationFailure | Error _ -> Lwt.return (db_created := false)
let () = Unix.sleepf 2.0
let () = if not !db_created then failwith "Could not initialize database"
let () = let () =
Dream.run Dream.run