clojure - How do I set the refer-to column value in Lobos? -


using lobos, migrations like:

(defmigration company-table   (up [] (create           (tbl :companies                (text name))))   (down [] (drop             (table :companies))))  (defmigration document-table   (up [] (create           (tbl :documents                (timestamp :date_of_event)                (text :title)                (text :name)                (refer-to :companies))))   (down [] (drop             (table :documents)))) 

i'd set refer-to on documents s.t. referring column name company_id, e.g. (refer-to :companies :company_id). how do this?

it doesn't documentation great, there 2 ways this:

  • using foreign-key function

(defmigration document-table   (up [] (create           (table :documents                (timestamp :date_of_event)                (text :title)                (text :name)                (foreign-key :company-id :companies)))) ;; or, if need specify options, you'd use                (foreign-key :company-id :companies :on-delete :cascade)))) 
  • using [:refer tname & options] option.

(defmigration document-table   (up [] (create           (table :documents                (timestamp :date_of_event)                (text :title)                (text :name)                (integer :company-id [:refer companies])))) ;; or, if need specify options, you'd use                (integer :company-id [:refer companies :on-delete :cascade])))) 

edit: also, unless defined own function tbl, mean table

edit 2: looks documentation here better.


Comments

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -