about summary refs log tree commit diff
path: root/finito-postgres
diff options
context:
space:
mode:
authorVincent Ambo <mail@tazj.in>2018-09-26T16·20+0200
committerVincent Ambo <mail@tazj.in>2018-09-26T16·20+0200
commit6e35c083bf95b3793c7b1800eae4357543fec363 (patch)
tree9cfa4fc205a0d3d6ab5a4ef9b485b46de3dcad71 /finito-postgres
parentcbb58fa6c2d60a72a454ba3c130bbcb990488643 (diff)
refactor(postgres): Minor changes to match actual table schema
Diffstat (limited to 'finito-postgres')
-rw-r--r--finito-postgres/src/lib.rs17
1 files changed, 10 insertions, 7 deletions
diff --git a/finito-postgres/src/lib.rs b/finito-postgres/src/lib.rs
index b7a0c4540f74..6e1815a69fa1 100644
--- a/finito-postgres/src/lib.rs
+++ b/finito-postgres/src/lib.rs
@@ -1,6 +1,8 @@
 //! PostgreSQL-backed persistence for Finito state machines
 //!
 //! This module implements ... TODO when I can write again.
+//!
+//! TODO: events & actions should have `SERIAL` keys
 
 #[macro_use] extern crate postgres;
 #[macro_use] extern crate postgres_derive;
@@ -97,6 +99,7 @@ struct ActionT {
     event_id: Uuid,
 
     /// Serialised content of the action.
+    #[postgres(name = "content")] // renamed because 'action' is a keyword in PG
     action: Value,
 
     /// Current status of the action.
@@ -105,7 +108,7 @@ struct ActionT {
     /// Serialised error representation, if an error occured during
     /// processing. TODO: Use some actual error type. Maybe failure
     /// has serialisation support?
-    error: Option<String>,
+    error: Option<Value>,
 }
 
 // The following functions implement the public interface of
@@ -149,8 +152,8 @@ pub fn insert_machine<C, S>(conn: &C, initial: S) -> Result<MachineId<S>> where
     C: GenericConnection,
     S: FSM + Serialize {
     let query = r#"
-      INSERT INTO machines (id, created, fsm, state)
-      VALUES ($1, NOW(), $2, $3)
+      INSERT INTO machines (id, fsm, state)
+      VALUES ($1, $2, $3)
     "#;
 
     let id = Uuid::new_v4();
@@ -171,8 +174,8 @@ where
     S: FSM,
     S::Event: Serialize {
     let query = r#"
-      INSERT INTO events (id, created, fsm, fsm_id, event)
-      VALUES ($1, NOW(), $2, $3, $4)
+      INSERT INTO events (id, fsm, fsm_id, event)
+      VALUES ($1, $2, $3, $4)
     "#;
 
     let id = Uuid::new_v4();
@@ -192,8 +195,8 @@ fn insert_action<C, S>(conn: &C,
     S: FSM,
     S::Action: Serialize {
     let query = r#"
-      INSERT INTO actions (id, created, fsm, fsm_id, event_id, action, status)
-      VALUES ($1, NOW(), $2, $3, $4, $5, $6)
+      INSERT INTO actions (id, fsm, fsm_id, event_id, action, status)
+      VALUES ($1, $2, $3, $4, $5, $6)
     "#;
 
     let id = Uuid::new_v4();