class Graffable::MigrationTask
Public Class Methods
new()
click to toggle source
# File lib/graffable/migration_task.rb, line 8 def initialize Sequel.extension :migration namespace = 'graffable:migrate' migrations = File.join( File.dirname(__FILE__), '../../db/migrations' ) desc 'Perform migration down (erase all data)' task "#{namespace}:down" do db = Graffable::Database.connect Sequel::Migrator.run db, migrations, target: 0 puts "<= #{namespace}:down executed" end desc 'Perform migration reset (full erase and migration up)' task "#{namespace}:reset" do db = Graffable::Database.connect Sequel::Migrator.run db, migrations, target: 0 Sequel::Migrator.run db, migrations puts "<= #{namespace}:reset executed" end desc 'Perform migration down (erase all data)' task "#{namespace}:down" do db = Graffable::Database.connect Sequel::Migrator.run db, migrations, target: 0 puts "<= #{namespace}:down executed" end desc 'Perform migration up/down to VERSION' task "#{namespace}:to" do version = ENV['VERSION'].to_i raise 'No VERSION was provided' if version.nil? db = Graffable::Database.connect Sequel::Migrator.run db, migrations, target: version puts "<= #{namespace}:to version=[#{version}] executed" end desc 'Perform migration to latest migration available' task "#{namespace}:up" do db = Graffable::Database.connect Sequel::Migrator.run db, migrations puts "<= #{namespace}:up executed" end end