Re: Add SQL comments in migrations

2021-02-26 Thread Mark Allen
Yep that does it. Had to make some broader changes since DB.extension(:pg_comment) was invoked outside of migrations since it has non-migration methods, such as DB.comment_for(:users__dob), to return the comment for users.dob. I think it's good to do now. Thanks On Fri, Feb 26, 2021 at 2:16 PM Je

Re: Add SQL comments in migrations

2021-02-26 Thread Jeremy Evans
On Fri, Feb 26, 2021 at 11:13 AM Mark Allen wrote: > Spoke a little too soon, when I move the previous code from inline @ the > top of my migration file, into the actual gem, there's what I assume is a > load-order issue. Seems like the gem is being loaded before > Sequel::MigrationReverser is de

Re: Add SQL comments in migrations

2021-02-26 Thread Mark Allen
Spoke a little too soon, when I move the previous code from inline @ the top of my migration file, into the actual gem, there's what I assume is a load-order issue. Seems like the gem is being loaded before Sequel::MigrationReverser is defined, so the reverser is not being updated obviously because

Re: Add SQL comments in migrations

2021-02-26 Thread Mark Allen
Perfect, I found this in pg_enum extension https://github.com/jeremyevans/sequel/blob/c24909f5182d633673c9e8d78813c24f0a4bbb88/lib/sequel/extensions/pg_enum.rb#L185-L197 Adapted to work with the comments gem and it seems to work great, that was way too easy hah. Thanks! if defined?(Sequel::Migrat

Re: Add SQL comments in migrations

2021-02-26 Thread Jeremy Evans
On Fri, Feb 26, 2021 at 10:10 AM Mark Allen wrote: > The main thing missing in the gem (once forked and updated to even run > properly at all) is reversible migration functions. Any advice or source > code you could link to that could give me an idea how to implement a > reversible migration meth

Re: Add SQL comments in migrations

2021-02-26 Thread Mark Allen
The main thing missing in the gem (once forked and updated to even run properly at all) is reversible migration functions. Any advice or source code you could link to that could give me an idea how to implement a reversible migration method that can be used in a `change` block? On Fri, Feb 26, 2

Re: SELECT DISTINCT in FROM clause

2021-02-26 Thread denniso...@gmail.com
Thank you, Jeremy! On Friday, February 26, 2021 at 8:04:10 PM UTC+3 Jeremy Evans wrote: > On Fri, Feb 26, 2021 at 8:58 AM denniso...@gmail.com > wrote: > >> Hi Jeremy, >> >> Based on my previous question, how do you use Sequel Models when FROM >> contains distinct? >> >> >> class Email < Seque

Re: SELECT DISTINCT in FROM clause

2021-02-26 Thread Jeremy Evans
On Fri, Feb 26, 2021 at 8:58 AM denniso...@gmail.com < dennisoconne...@gmail.com> wrote: > Hi Jeremy, > > Based on my previous question, how do you use Sequel Models when FROM > contains distinct? > > > class Email < Sequel::Model; end > > SELECT > name, > string_agg(user_id::text, ',' ord

Re: Exclude column/field from being saved with models

2021-02-26 Thread denniso...@gmail.com
Exactly. Thank you! On Thursday, February 25, 2021 at 6:29:28 PM UTC+3 adam.me...@gmail.com wrote: > You're likely looking for the split_values plugin. > > > http://sequel.jeremyevans.net/rdoc-plugins/classes/Sequel/Plugins/SplitValues.html > > On Thursday, February 25, 2021 at 8:18:39 AM UTC-5

Re: How to use string_agg with CAST and Distinct?

2021-02-26 Thread denniso...@gmail.com
Thanks, Jeremy. It worked. On Thursday, February 25, 2021 at 6:59:27 PM UTC+3 Jeremy Evans wrote: > On Wed, Feb 24, 2021 at 7:24 PM denniso...@gmail.com > wrote: > >> Hi Jeremy, >> >> I am bit lost for string_agg in PostgreSQL when converting to Sequel. >> >> How can I write this code with Sequ

SELECT DISTINCT in FROM clause

2021-02-26 Thread denniso...@gmail.com
Hi Jeremy, Based on my previous question, how do you use Sequel Models when FROM contains distinct? class Email < Sequel::Model; end SELECT name, string_agg(user_id::text, ',' order by ordering desc) FROM ( SELECT DISTINCT ON (em.id, c.user_id) * FROM emails em JOI

Re: Add SQL comments in migrations

2021-02-26 Thread Jeremy Evans
On Fri, Feb 26, 2021 at 8:11 AM mark@vydia.com wrote: > Hi Jeremy & all, > > I'm looking for the best approach for adding postgresql comments to tables > & columns in migrations. I looked around in sequel docs for any first-class > support for this, but could not find it — maybe I'm not seein

Re: DateTime/Time conversion issue

2021-02-26 Thread Jeremy Evans
On Fri, Feb 26, 2021 at 7:25 AM Michael Davis wrote: > Your explanation about daylight savings would make since if all the dates > converted in the same way meaning when I convert them to localtime, I get > the same date back. One date comes back MST with the right time as > expected and another

Add SQL comments in migrations

2021-02-26 Thread mark....@vydia.com
Hi Jeremy & all, I'm looking for the best approach for adding postgresql comments to tables & columns in migrations. I looked around in sequel docs for any first-class support for this, but could not find it — maybe I'm not seeing a specific plugin somewhere. The only thing I could find was th

Re: DateTime/Time conversion issue

2021-02-26 Thread Michael Davis
Your explanation about daylight savings would make since if all the dates converted in the same way meaning when I convert them to localtime, I get the same date back. One date comes back MST with the right time as expected and another comes back CST with right time but they are off by an hour