Sha256: ce3e8cc8ded9f48e2910b2f42dc088b49a78d47cb890b957ce3c6f14c8fc7e39

Contents?: true

Size: 1.23 KB

Versions: 1

Compression:

Stored size: 1.23 KB

Contents

namespace :restpack do
  desc "Run any outstanding RestPack migrations"
  task :migrate do
    Rake::Task["restpack:activity:migrate"].invoke
  end

  desc "List RestPack configuration"
  task :configuration do
    Rake::Task["restpack:activity:configuration"].invoke
  end

  namespace :core do
    desc "Run any outstanding RestPack::Core migrations"
    task :migrate => ["connection"] do
      source_migrations_path = File.dirname(__FILE__) + "/../../../db/migrate"
      target_migrations_path = "db/migrate"

      ActiveRecord::Migration.verbose = true
      ActiveRecord::Migrator.migrate(source_migrations_path)

      if File.directory?(target_migrations_path)
        FileUtils.cp_r(Dir["#{source_migrations_path}/*"], target_migrations_path)
      end
    end

    task :connection do
      config = YAML.load(IO.read('config/database.yml'))
      environment = ENV['RAILS_ENV'] || ENV['DB'] || 'development'
      ActiveRecord::Base.establish_connection config[environment]
    end

    desc "List RestPack::Core::Service configuration"
    task :configuration do
      p "RestPack::Core::Service Configuration"
      p "--------------------------------"
      p "db_table_prefix: #{RestPack::Core::Service.config.db_table_prefix}"
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
restpack_core_service-0.0.5 lib/restpack_core_service/tasks/db.rake