class SingerHeroku::RakeTasks

Rake tasks for migrating development database

Public Instance Methods

install_tasks() click to toggle source

rubocop:disable Rails/Output

# File lib/rake_tasks.rb, line 11
def install_tasks
  namespace :singer_heroku do
    desc 'Run migrations'
    task :migrate, [:version] do |_t, args|
      Sequel.extension :migration
      db = Sequel.connect(ENV.fetch('DATABASE_URL'))
      version = args[:version]
      puts "Migrating to #{version || 'latest'}"
      version = version&.to_i
      Sequel::Migrator.run(db, 'db/migrations', target: version)
    end
  end
end