This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-08-16
Channels
- # announcements (25)
- # babashka (15)
- # beginners (14)
- # calva (60)
- # circleci (1)
- # clerk (1)
- # clj-kondo (13)
- # cljdoc (7)
- # clojure (45)
- # clojure-austin (1)
- # clojure-bay-area (1)
- # clojure-brasil (4)
- # clojure-dev (9)
- # clojure-europe (24)
- # clojure-norway (105)
- # clojure-uk (2)
- # clojurescript (6)
- # conjure (1)
- # core-typed (4)
- # cursive (4)
- # datalevin (1)
- # datomic (25)
- # emacs (31)
- # fulcro (3)
- # humbleui (10)
- # hyperfiddle (19)
- # jobs (2)
- # luminus (3)
- # malli (13)
- # nbb (5)
- # off-topic (16)
- # polylith (2)
- # portal (7)
- # releases (2)
- # shadow-cljs (5)
- # sql (8)
Would be nice to include postgres "CREATE INDEX" in HoneySQL. I'm for now running with this for the simplest case:
(sql/register-clause! ::create-index-on
(fn [clause x]
[(str (sql/sql-kw clause) " " (sql/format-entity x))])
:columns)
and using it like
{::rdb/create-index-on :bank-transaction
:columns [:bank-transaction/case-id
:bank-transaction/date]}
(sql/register-clause!
:create-index
(fn [_ {idx-name :name
:keys [unique?
if-not-exists?
on-table
on-field
using]}]
[(clojure.string/join
" "
["CREATE"
(when unique? "UNIQUE")
"INDEX"
(when if-not-exists? "IF NOT EXISTS")
(name idx-name)
"ON"
(name on-table)
"(" (name on-field) ")"
(when using "USING")
(when using using)])])
(sql/format {:create-index
{:if-not-exists? true
:name "idx_user_lname"
:on-table :users
:on-field :lname}})
["CREATE INDEX IF NOT EXISTS idx_user_lname
ON users ( lname )"]
I use it in the same way as SQL. I just introduced migratus
for managing the versioning.
DDL is mostly non-ANSI Standard in practice so each statement tends to vary a lot between dialects. HoneySQL supports the most common "core" DDL -- so there's basic ALTER TABLE
/ ADD INDEX
stuff -- but a lot of each database's DDL is very irregular in structure and hard to model in a data-driven DSL.
Feel free to create an issue on GitHub and I'll see about putting in basic CREATE INDEX
(based on the machinery of alter/add I expect).