summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/main.rs8
-rw-r--r--src/serve.rs2
2 files changed, 6 insertions, 4 deletions
diff --git a/src/main.rs b/src/main.rs
index c6b7d86..b0bda1b 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -10,12 +10,12 @@ use std::sync::{Arc, Mutex};
lazy_static! {
static ref CLIENT: Arc<Mutex<Client>> = Arc::new(Mutex::new(
- Client::connect("host=localhost user=postgres password=example", NoTls).unwrap()
+ Client::connect("host=track_db user=postgres password=example", NoTls).unwrap()
));
}
fn main() {
- //initialize_db().unwrap();
+ initialize_db().unwrap();
//setup_db().unwrap();
println!("connected with db");
rocket::ignite()
@@ -44,9 +44,11 @@ fn setup_db() -> Result<(), postgres::Error> {
fn initialize_db() -> Result<(), postgres::Error> {
let mut client = CLIENT.lock().unwrap();
+ let _ = client.batch_execute(
+ "DROP TABLE user_track; DROP TABLE suser; DROP TABLE track;"
+ );
client.batch_execute(
"
- DROP TABLE user_track; DROP TABLE suser; DROP TABLE track;
CREATE TABLE track (
track_id SERIAL PRIMARY KEY,
track_code TEXT NOT NULL UNIQUE,
diff --git a/src/serve.rs b/src/serve.rs
index 5696f12..babb3fe 100644
--- a/src/serve.rs
+++ b/src/serve.rs
@@ -100,7 +100,7 @@ pub fn get_tracks(name: String, url: String) -> String {
VALUES ($1, $2, $3)
ON CONFLICT
ON CONSTRAINT track_user_pkey
- DO UPDATE;",
+ DO NOTHING;",
&[&tid, &uid, &0],
)
.unwrap();