Sha256: 8d8f0211513a59add95aa2e1ddab7475c83317faf330b72f51391e7b2b4aa09d

Contents?: true

Size: 993 Bytes

Versions: 4

Compression:

Stored size: 993 Bytes

Contents

# frozen_string_literal: true

namespace :ridgepole do
  desc 'Apply database schema'
  task apply: :environment do
    ridgepole('--apply', "-E #{Rails.env}", "--file #{schema_file}")
    Rake::Task['db:schema:dump'].invoke if Rails.env.development?
    Rake::Task['annotate_models'].invoke if Rails.env.development?
  end

  desc 'Export database schema'
  task export: :environment do
    ridgepole('--export', "-E #{Rails.env}", '--split', "--output #{schema_file}")
  end

  desc 'import seed data'
  task seed: :environment do
    path = Rails.root.join("db/seeds/#{Rails.env}.rb")
    path = path.sub(Rails.env, ENV.fetch('RAILS_ENV', 'development')) unless File.exist?(path)

    require path
  end

  private

  def schema_file
    Rails.root.join('db/Schemafile')
  end

  def config_file
    Rails.root.join('config/database.yml')
  end

  def ridgepole(*options)
    command = ['bundle exec ridgepole', "--config #{config_file}"]
    system [command + options].join(' ')
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
ibrain-core-0.3.2.pre.rc.3 lib/tasks/ibrain/ridgepole.rake
ibrain-core-0.3.2.pre.rc lib/tasks/ibrain/ridgepole.rake
ibrain-core-0.3.2 lib/tasks/ibrain/ridgepole.rake
ibrain-core-0.3.1 lib/tasks/ibrain/ridgepole.rake