Sha256: 901c79d264b9032db7449105b320bf90857b411e8238cb23a5fb852fec5c1193

Contents?: true

Size: 991 Bytes

Versions: 1

Compression:

Stored size: 991 Bytes

Contents

require "yaml"

namespace :db do

  database_url = YAML.load_file("./config/database.yml")["default"]["url"]

  desc "Perform migration reset (full erase and migration up)"
  task :setup do
    puts `sequel -Etm ./db/migrations -M 0 #{database_url}`
    puts `sequel -Etm ./db/migrations #{database_url}`
    puts "<= sq:migrate:reset executed"
  end

  desc "Perform migration up/down to VERSION"
  task :version do
    version = ENV['VERSION'].to_i
    raise "No VERSION was provided" if version.nil?
    puts `sequel -Etm db/migrations -M #{version} #{database_url}`
    puts "<= sq:migrate:to version=[#{version}] executed"
  end

  desc "Perform migration up to latest migration available"
  task :migrate do
    puts `sequel -Etm ./db/migrations #{database_url}`
    puts "<= sq:migrate:up executed"
  end

  desc "Perform migration down (erase all data)"
  task :rollback do
    puts `sequel -Etm ./db/migrations -M 0 #{database_url}`
    puts "<= sq:migrate:down executed"
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
simba-0.0.4 lib/simba/base_app/lib/tasks/db.rake