Sha256: b08576ed08104d7a56e832ee13981f093dd1e6898cdfaecfce8d8307812b0aa8

Contents?: true

Size: 1.75 KB

Versions: 4

Compression:

Stored size: 1.75 KB

Contents

namespace :storey do

  namespace :hstore do
    desc "Install hstore into the hstore#{Storey.configuration.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

4 entries across 4 versions & 1 rubygems

Version Path
storey-2.2.0 lib/tasks/storey.rake
storey-2.1.2 lib/tasks/storey.rake
storey-2.1.1 lib/tasks/storey.rake
storey-2.1.0 lib/tasks/storey.rake