Fork me on GitHub
#honeysql
<
2021-02-13
>
seancorfield00:02:50

Q for folks using nilenso/honeysql-postgres: how many of you actually use alter-table (and the undocumented rename-table)? It looks like it doesn't currently let you have multiple altering clauses (e.g., alter table foo add column id int, drop column ident; type stuff). Would a syntax allowing multiple clauses be appreciated?

seancorfield00:02:57

I'm thinking of something like:

{:alter-table :foo :add-column [:id :int]} ; single clause case
(-> (alter-table :foo) (add-column :id :int)) ; single clause helper version
;; proposed:
{:alter-table [:foo {:add-column [:id :int]} {:drop-column :ident}]} ; multi-clause case
(alter-table :foo (add-column :id :int) (:drop-column :ident)) ; multi-clause helper version

Kevin21:02:15

Yes it would be nice to have!

Kevin21:02:03

If Honeysql would get first class support for creating / altering tables etc. It would simplify it for my library and I'd get rid of an extra dependency 🙂

Kevin21:02:45

(I currently use this to implement my migration system)

seancorfield22:02:33

@UG9U7TPDZ Thanks for the feedback -- I'm most of the way through integrating and testing the last few parts of the nilenso library this afternoon (`do update set` is giving me fits! 👀 ) but by Monday this should all be sorted out and documented (integrating all these clauses in a consistent manner has led to some divergence -- so I plan to write a full "differences" page in the documentation).

👍 3
seancorfield05:02:29

And another PG Q about that library: is anyone actually using create-extension and/or drop-extension? What on earth do those even mean?

Chris O’Donnell06:02:28

I don't use honeysql for ddl, but create and drop extension are for enabling and disabling postgres extensions (https://www.postgresql.org/docs/current/external-extensions.html), which are basically plug-ins adding functionality to postgres. For example, PostGIS is a popular extension adding spatial and geographic data types.

3
Kevin20:02:56

I use it to enable uuids

3
dharrigan07:02:18

Morning - whilst I don't use alter table/rename table clauses, perhaps in the name of completeness they should be included (if minimal work involved!)

dharrigan07:02:35

Yeah, create and drop extensions are for installing extensions within schemas

dharrigan07:02:48

for example "create extension postgis schema foo"

dharrigan07:02:56

would install the postgis extension into schema foo

dharrigan07:02:09

there are lots of extensions

dharrigan07:02:51

The problem, perhaps, with alter table (including it's rename variant) is there are tonnes of options on how to alter/create the table.

dharrigan07:02:15

Would it be too much effort?

dharrigan07:02:33

The way I use those clauses (create schema, alter table etc...) is only in my migration scripts (I use flywaydb). Since i would expect these to run on application start.

seancorfield17:02:02

@dharrigan Thanks for that feedback. I ended up implementing add/drop/modify/rename column and add/drop index. I may implement more if folks request it. I'll go ahead and implement create/drop extension then since nilenso does have it.

seancorfield17:02:52

I also added rename table (that's in the nilenso library but not documented -- seems there are quite a few things implemented and not documented there, so at least they'll all get documented now in HoneySQL v2!)

dharrigan17:02:32

I've finished off testing my application, works perfectly with minimal changes to support honeysql v2

seancorfield17:02:40

Brilliant! Thank you!

seancorfield17:02:31

Today I'm going to post over the nilenso test suite and adjust it to work with v2 to check I have everything implemented.

dharrigan17:02:49

you're most welcome 🙂