On Tuesday, June 27, 2017 at 2:45:16 PM UTC-7, Avi Flax wrote:
>
>
> > On Jun 27, 2017, at 17:34, Jeremy Evans <[email protected]> wrote: 
> > 
> > Not all indexes can be dumped cross database.  If your are not using the 
> :same_db option when dumping, you are dumping indexes, and there are 
> indexes on the table, :ignore_index_errors=>true is added to make it more 
> likely the migration can be restored.  Here's the commit that added this 
> code: 
> https://github.com/jeremyevans/sequel/commit/09214bc4bd15f6dc4499d6e6ef7c6e5807b048fb
>  
>
> That makes sense. Thank you for explaining! 
>
> I totally understand the rationale behind the option existing, and behind 
> it being the default — it all seems very sensible and thoughtful. 
>
> However, it did end up leading to the problem I experienced, wherein one 
> of the indices could not be created, the error was swallowed (ignored), and 
> that prevented the transaction from being committed — with an error message 
> that didn’t help point me in the right direction. 
>
> Given that, I wonder if there might be some way to prevent this specific 
> scenario from causing problems for other folks. Unfortunately I don’t have 
> any specific ideas — sorry. 
>

This should fix that problem:

diff --git a/lib/sequel/database/schema_methods.rb 
b/lib/sequel/database/schema_methods.rb
index c4c965d8..42915e7c 100644
--- a/lib/sequel/database/schema_methods.rb
+++ b/lib/sequel/database/schema_methods.rb
@@ -707,7 +707,7 @@ module Sequel
       e = options[:ignore_index_errors] || options[:if_not_exists]
       generator.indexes.each do |index|
         begin
-          index_sql_list(name, [index]).each{|sql| execute_ddl(sql)}
+          transaction(:savepoint=>:only){index_sql_list(name, 
[index]).each{|sql| execute_ddl(sql)}}
         rescue Error
           raise unless e
         end

I'll see if I can test that behavior and commit it before the next release.

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 https://groups.google.com/group/sequel-talk.
For more options, visit https://groups.google.com/d/optout.

Reply via email to