Sha256: cd9a7e88b1ac9747fb03d42450a1b8c903792739f9111a04707be652cb2edd41

Contents?: true

Size: 1.73 KB

Versions: 9

Compression:

Stored size: 1.73 KB

Contents

namespace :storey do

  namespace :hstore do
    desc "Install hstore into the hstore#{Storey.suffix} schema"
    task :install => :environment do
      Storey::Hstore.install
    end
  end

  desc "Migrate all schemas including public"
  task migrate: :environment do
    options = {}
    options[:version] = ENV['VERSION']
    Storey::Migrator.migrate_all options
  end

  desc "Rolls the schema back to the previous version (specify steps w/ STEP=n) across all schemas."
  task :rollback => :environment do
    step = ENV['STEP'] ? ENV['STEP'].to_i : 1
    Storey::Migrator.rollback_all(step)
  end

  namespace :migrate do

    desc 'Runs the "up" for a given migration VERSION across all schemas.'
    task :up => 'db:migrate:up' do
      version = ENV['VERSION'] ? ENV['VERSION'].to_i : nil
      raise 'VERSION is required' unless version

      Storey.schemas.each do |schema|
        puts "Migrating #{schema} schema up"
        Storey::Migrator.run :up, schema, version
      end
    end

    desc 'Runs the "down" for a given migration VERSION across all schemas.'
    task :down => 'db:migrate:down' do
      version = ENV['VERSION'] ? ENV['VERSION'].to_i : nil
      raise 'VERSION is required' unless version

      Storey.schemas.each do |schema|
        puts "Migrating #{schema} schema down"
        Storey::Migrator.run :down, schema, version
      end
    end

    desc 'Rollbacks the database one migration and re migrate up (options: STEP=x, VERSION=x).'
    task :redo => 'db:migrate:redo' do
      if ENV['VERSION']
        apartment_namespace['migrate:down'].invoke
        apartment_namespace['migrate:up'].invoke
      else
        apartment_namespace['rollback'].invoke
        apartment_namespace['migrate'].invoke
      end
    end

  end

end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
storey-2.0.2 lib/tasks/storey.rake
storey-2.0.1 lib/tasks/storey.rake
storey-2.0.0 lib/tasks/storey.rake
storey-1.0.0 lib/tasks/storey.rake
storey-0.6.0 lib/tasks/storey.rake
storey-0.5.2 lib/tasks/storey.rake
storey-0.5.1 lib/tasks/storey.rake
storey-0.5.0 lib/tasks/storey.rake
storey-0.4.2 lib/tasks/storey.rake