An alternative Ludum Dare entries viewer.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

46 lines
1.5 KiB

(ns ldview.models.schema
(:require [clojure.java.jdbc :as sql]
[noir.io :as io]))
(def db-store (str "resources/site.db"))
(def db-spec {:classname "org.sqlite.JDBC"
:subprotocol "sqlite"
:subname db-store})
(defn initialized? []
(.exists (new java.io.File db-store)))
(defn create-initial-tables []
(sql/with-connection db-spec
(sql/create-table :entries
[:id "INTEGER PRIMARY KEY AUTOINCREMENT"]
[:ld_uid "INTEGER"]
[:title "VARCHAR(255)"]
[:description "TEXT"]
[:type "VARCHAR(255)"]
[:user_id "INTEGER"]
[:competition_id "INTEGER"])
(sql/create-table :users
[:id "INTEGER PRIMARY KEY AUTOINCREMENT"]
[:name "VARCHAR(255)"])
(sql/create-table :competitions
[:id "INTEGER PRIMARY KEY AUTOINCREMENT"]
[:number "INTEGER"]
[:motto "VARCHAR(255)"])
(sql/create-table :sources
[:id "INTEGER PRIMARY KEY AUTOINCREMENT"]
[:entry_id "INTEGER"]
[:type "VARCHAR(100)"]
[:uri "VARCHAR(255)"])
(sql/do-commands "CREATE INDEX ld_uid_index ON entries (ld_uid)")
(sql/do-commands "CREATE INDEX entry_id_index ON sources (entry_id)")))
(defn create-tables []
(if-not (initialized?)
(create-initial-tables)))