Created
November 2, 2014 18:06
-
-
Save plukevdh/2b8e917a550aba930053 to your computer and use it in GitHub Desktop.
migrations a la sequel
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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