From 2632a0cab494a7ccce327084154ace73a6864282 Mon Sep 17 00:00:00 2001 From: dave griffiths Date: Tue, 5 Sep 2017 14:47:04 +0000 Subject: [PATCH] changes for new column --- eavdb/eavdb.ss | 5 +++-- eavdb/entity-insert.ss | 4 ++-- eavdb/entity-values.ss | 4 ++-- web/run | 2 +- web/scripts/sql.ss | 3 ++- web/server.scm | 2 +- 6 files changed, 11 insertions(+), 9 deletions(-) diff --git a/eavdb/eavdb.ss b/eavdb/eavdb.ss index 2defa02..72a2131 100644 --- a/eavdb/eavdb.ss +++ b/eavdb/eavdb.ss @@ -37,8 +37,9 @@ (define (upgrade-table db name) - (db-exec db (string-append "alter table " name " add version integer"))) - + (db-exec db (string-append "alter table " name " add version integer")) + (db-exec db (string-append "alter table " name " add sent integer default 0")) + ) ;; create eav tables (add types as required) (define (setup db table) diff --git a/eavdb/entity-insert.ss b/eavdb/entity-insert.ss index 0a508a7..5affaf0 100644 --- a/eavdb/entity-insert.ss +++ b/eavdb/entity-insert.ss @@ -54,7 +54,7 @@ (db-exec db "begin transaction") (let ((id (db-insert db (string-append - "insert into " table "_entity values (null, ?, ?, ?, ?)") + "insert into " table "_entity (entity_id, entity_type, unique_id, dirty, version) values (null, ?, ?, ?, ?)") entity-type unique-id dirty version))) ;; create the attributes if they are new, and validate them if they exist @@ -78,7 +78,7 @@ (db-exec db "begin transaction") (let ((id (db-insert db (string-append - "insert into " table "_entity values (?, ?, ?, ?, ?)") + "insert into " table "_entity (entity_id, entity_type, unique_id, dirty, version) values (?, ?, ?, ?, ?)") id entity-type unique-id dirty version))) ;; create the attributes if they are new, and validate them if they exist diff --git a/eavdb/entity-values.ss b/eavdb/entity-values.ss index d06ecaa..5d5a22b 100644 --- a/eavdb/entity-values.ss +++ b/eavdb/entity-values.ss @@ -41,7 +41,7 @@ ((null? t) (msg "adding new attribute for" entity-type " called " key " of type " type) (db-insert - db (string-append "insert into " table "_attribute values (null, ?, ?, ?)") + db (string-append "insert into " table "_attribute (id, attribute_id, entity_type, attribute_type) values (null, ?, ?, ?)") key entity-type type) type) (else @@ -58,7 +58,7 @@ (define (insert-value db table entity-id ktv dirty) ;; use type to dispatch insert to correct value table (db-insert db (string-append "insert into " table "_value_" (ktv-type ktv) - " values (null, ?, ?, ?, ?, 0)") + "(id, entity_id, attribute_id, value, dirty, version) values (null, ?, ?, ?, ?, 0)") entity-id (ktv-key ktv) (ktv-value ktv) (if dirty 1 0))) ;; update the value given an entity type, a attribute type and it's key (= attriute_id) diff --git a/web/run b/web/run index ea3c015..008552c 100755 --- a/web/run +++ b/web/run @@ -1,4 +1,4 @@ #!/bin/bash -./server.scm 8888 >>client/htdocs/log.txt 2>&1 +./server.scm 8888 >client/htdocs/log.txt 2>&1 diff --git a/web/scripts/sql.ss b/web/scripts/sql.ss index 1ce8c38..1ecc6ff 100644 --- a/web/scripts/sql.ss +++ b/web/scripts/sql.ss @@ -34,12 +34,13 @@ ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; fix this mess (define (db-open db-name setup-fn) (cond ((file-exists? (string->path db-name)) (display "open existing db")(newline) (let ((db (open (string->path db-name)))) - ;; upgrade... + ;; upgrade (setup-fn db "sync") (setup-fn db "stream") db)) diff --git a/web/server.scm b/web/server.scm index 5e224f0..ffe24c0 100755 --- a/web/server.scm +++ b/web/server.scm @@ -198,7 +198,7 @@ start ;; port number is read from command line as argument ;; ie: ./server.scm 8080 -;; #:listen-ip "192.168.2.1" + #:listen-ip "192.168.2.1" #:port (string->number (command-line #:args (port) port)) #:command-line? #t #:servlet-path "/mongoose"