On Friday, August 28, 2015 at 3:56:50 AM UTC-7, Paul Cowan wrote:
>
> I am curious if the following would have been possible in a migration.  I 
> had to use raw sql
>
>
>     run <<-SQL
>       UPDATE deals
>       SET list_id=ls.id
>       FROM (SELECT id, account_id from lists where name = 'Opportunities') 
> AS ls
>       WHERE deals.account_id=ls.account_id;
>     SQL
>
> Could I have used the sequel migration DSL to do the same?
>

Yes:

from(:deals, from(:lists).where(:name=>'Opportunities').select(:id, 
:account_id).as(:ls)).
  where(:deals__account_id=>:ls__account_id).
  update(:list_id=>:ls__id)

Thanks,
Jeremy

-- 
You received this message because you are subscribed to the Google Groups 
"sequel-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sequel-talk.
For more options, visit https://groups.google.com/d/optout.

Reply via email to