Sha256: 76322ae3f4a82e6cfaeba5fbb3c3a29abaaa55dee145a6c0e9d5c09d43cd8b12

Contents?: true

Size: 1.91 KB

Versions: 8

Compression:

Stored size: 1.91 KB

Contents

# encoding: utf-8
module MagicRecipes
  module Db
    def self.load_into(configuration)
      configuration.load do
        
        namespace :db do
          
          desc "seed the database"
          task :seed do
            if use_rvm
              run <<-CMD
                #{rvm_cmd} && 
                cd #{latest_release} && 
                #{rake} db:seed RAILS_ENV=#{rails_env}
              CMD
            else
              run "cd #{latest_release} && #{rake} db:seed RAILS_ENV=#{rails_env}"
            end
          end
  
          desc "migrate the database"
          task :migrate do
            if use_rvm
              run <<-CMD
                #{rvm_cmd} && 
                cd #{latest_release} && 
                #{rake} db:migrate RAILS_ENV=#{rails_env}
              CMD
            else
              run "cd #{latest_release} && #{rake} db:migrate RAILS_ENV=#{rails_env}"
            end
          end
          
          desc "delete all Tables of the Database!"
          task :delete_tables do
            if use_rvm
              run <<-CMD
                #{rvm_cmd} && 
                cd #{latest_release} && 
                RAILS_ENV=#{rails_env} rails runner "ActiveRecord::Base.connection.tables.each { |t| ActiveRecord::Base.connection.drop_table t }"
              CMD
            else
              run "cd #{latest_release} && RAILS_ENV=#{rails_env} rails runner 'ActiveRecord::Base.connection.tables.each { |t| ActiveRecord::Base.connection.drop_table t }'"
            end
            # => ActiveRecord::Base.connection.tables.each { |t| ActiveRecord::Base.connection.drop_table t }
          end
          
          desc "DB-Reset for user without dbcreate permission (deletes all tables than migrates again)"
          task :save_reset do
            delete_tables
            migrate
          end
          
        end
        
        # eof
        
      end
    end
  end
end



        

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
magic_recipes-0.0.19 lib/magic_recipes/db.rb
magic_recipes-0.0.18 lib/magic_recipes/db.rb
magic_recipes-0.0.17 lib/magic_recipes/db.rb
magic_recipes-0.0.16 lib/magic_recipes/db.rb
magic_recipes-0.0.15 lib/magic_recipes/db.rb
magic_recipes-0.0.14 lib/magic_recipes/db.rb
magic_recipes-0.0.13 lib/magic_recipes/db.rb
magic_recipes-0.0.12 lib/magic_recipes/db.rb