From 56c6670c66ff7db2e30378b098102578e75f98fb Mon Sep 17 00:00:00 2001 From: pommicket Date: Tue, 13 Aug 2024 21:33:36 -0400 Subject: start puzl --- server/src/main.rs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'server/src') diff --git a/server/src/main.rs b/server/src/main.rs index eb9674b..1ec62a6 100644 --- a/server/src/main.rs +++ b/server/src/main.rs @@ -35,7 +35,18 @@ struct Server { impl Server { async fn create_table_if_not_exists(&self) -> Result<()> { - todo!() + if self.database.query("SELECT FROM puzzles", &[]).await.is_ok() { + return Ok(()); + } else { + self.database.execute("CREATE TABLE puzzles ( + id char($1) PRIMARY KEY, + url varchar(256), + create_time timestamp, + connectivity int2[], + positions float4[] + )", &[&(PUZZLE_ID_LEN as i32)]).await?; + return Ok(()); + } } async fn try_register_id(&self, id: [u8; PUZZLE_ID_LEN]) -> Result { todo!() -- cgit v1.2.3