Skip to content

Instantly share code, notes, and snippets.

@plukevdh
Created November 2, 2014 18:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save plukevdh/2b8e917a550aba930053 to your computer and use it in GitHub Desktop.
Save plukevdh/2b8e917a550aba930053 to your computer and use it in GitHub Desktop.
migrations a la sequel
namespace :db do
desc "Run migrations"
task :migrate, [:version] do |t, args|
require "sequel"
Sequel.extension :migration
db = Sequel.connect(ENV.fetch("DATABASE_URL"))
if args[:version]
puts "Migrating to version #{args[:version]}"
Sequel::Migrator.run(db, "db/migrations", target: args[:version].to_i)
else
puts "Migrating to latest"
Sequel::Migrator.run(db, "db/migrations")
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment