summaryrefslogtreecommitdiff
path: root/server/src
diff options
context:
space:
mode:
Diffstat (limited to 'server/src')
-rw-r--r--server/src/main.rs13
1 files changed, 12 insertions, 1 deletions
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<bool> {
todo!()