namespace :db do desc "Run Sequel migrations" task :migrate => :environment, [:version] do |t, args| Sequel.extension :migration db = Sequel.connect(ENV.fetch("DATABASE_URL")) if args[:version] puts "Migrating to version #{args[:version]}" Sequel::Migrator.run(db, "#{$app_root}/db/migrations", target: args[:version].to_i) else puts "Migrating to latest" Sequel::Migrator.run(db, "#{$app_root}/db/migrations") end end end