Skip to content

Commit

Permalink
changes for new column
Browse files Browse the repository at this point in the history
  • Loading branch information
nebogeo committed Sep 5, 2017
1 parent 8587b1c commit 2632a0c
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 9 deletions.
5 changes: 3 additions & 2 deletions eavdb/eavdb.ss
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions eavdb/entity-insert.ss
Expand Up @@ -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
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions eavdb/entity-values.ss
Expand Up @@ -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
Expand All @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion 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


3 changes: 2 additions & 1 deletion web/scripts/sql.ss
Expand Up @@ -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))
Expand Down
2 changes: 1 addition & 1 deletion web/server.scm
Expand Up @@ -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"
Expand Down

0 comments on commit 2632a0c

Please sign in to comment.