Sha256: 064d2e4d818cd4b6bb0eb52aa3126c0e66e8e2e54c353936e1a0ba8d3a849c3a

Contents?: true

Size: 1.22 KB

Versions: 4

Compression:

Stored size: 1.22 KB

Contents

namespace :db do

  desc "Generate all the database objects of the current project"
  task :create_objects => :environment do
    creator = RailsDbObjects::DbObjectsCreator.new

    objects_path, objects_ext = Rails.configuration.rails_db_objects[:objects_path], Rails.configuration.rails_db_objects[:objects_ext]

    objects_path.each do |path|
      creator.register_files Dir[File.join(path, objects_ext)].map {|x|
        File.expand_path(x)
      }
    end

    creator.create_objects
  end

  desc "Drop all the database objects of the current project"
  task :drop_objects => :environment do
    creator = RailsDbObjects::DbObjectsCreator.new

    objects_path, objects_ext = Rails.configuration.rails_db_objects[:objects_path], Rails.configuration.rails_db_objects[:objects_ext]

    objects_path.each do |path|
      creator.register_files Dir[File.join(path, objects_ext)].map{|x| File.expand_path(x)}
    end

    creator.drop_objects
  end
end

require 'rake/hooks'

before "db:migrate" do
  Rake::Task['db:drop_objects'].invoke
end
before "db:rollback" do
  Rake::Task['db:drop_objects'].invoke
end

after "db:migrate" do
  Rake::Task['db:create_objects'].invoke
end
after "db:rollback" do
  Rake::Task['db:create_objects'].invoke
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
rails_db_objects-0.0.4 lib/tasks/rails_db_objects_tasks.rake
rails_db_objects-0.0.3 lib/tasks/rails_db_objects_tasks.rake
rails_db_objects-0.0.2 lib/tasks/rails_db_objects_tasks.rake
rails_db_objects-0.0.1 lib/tasks/rails_db_objects_tasks.rake