On Mon, Jul 13, 2015 at 06:01:58PM -0700, Jeremy Evans wrote:
>
> (...)
>
> Note that the above will only work if you use transactional migrations.
> Hopefully you can play around with that and get something that works for
> you.
Hello Jeremy,
thanks for your answer and all the insight.
I ended up wrapping the migrator like this:
```ruby
require 'optparse'
require 'xxx/db' # where DB is defined
require 'sequel/extensions/migration'
dry = false
from = nil
to = nil
OptionParser.new { |opts|
opts.on('-d', '--dry', 'run dry, only output sql') { dry = true }
opts.on('-f', '--from [MIG]', Integer, 'origin migration') { |i| from = i }
opts.on('-t', '--to [MIG]', Integer, 'target migration') { |i| to = i }
opts.on_tail('-h', '--help', "Show this message") { puts(opts); exit }
}.parse!(ARGV)
if dry || %w[ 1 yes true ].include?(ENV['MIGDRY'])
class Sequel::JDBC::Database
def execute(sql, opts=OPTS, &block)
puts sql
end
end
DB.loggers.clear
puts "--"
puts "-- ENV '#{XXXENV}'" # test, dev, uat, production, ...
puts "-- from #{from.inspect} to #{to.inspect}"
puts "--"
end
Sequel::Migrator.apply(DB, 'migrations', to, from)
```
Since I'm using JDBC it was easy to modify Database#execute.
So far, it seems OK.
Thanks again,
John
--
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.