Sha256: 17458fe4eb5b8cfff82469e7568e33f13e5340f6999ea88001f20ca69aca4e9d

Contents?: true

Size: 1.83 KB

Versions: 27

Compression:

Stored size: 1.83 KB

Contents

# encoding: utf-8
module MagicRecipes
  # = RVM - Deploy-Recipes
  # 
  # This is more for test & try pupose. Save .sqlite and copy to current after deploy.
  # 
  # [Tasks:]
  #   :setup_db       # => Create shared folder.
  # 
  #   :save_db        # => Copy current DB to shared folder.
  # 
  #   :copy_db        # => Copy saved DB from shared folder to current_release
  # 
  # [Callbacks:]
  #   after "deploy:setup", "sqlite:setup_db"
  # 
  #   more in deploy.rb ! .. becasuse ist just in case you need it .. and only works after second deploy !
  # 
  module Sqlite
    def self.load_into(configuration)
      configuration.load do

        set_default :sqlite_path,         "#{ deploy_to }/shared/db/"
        set_default :sqlite_db,           "#{ rails_env.downcase.strip }"

        namespace :sqlite do
          
          desc "setup shared sqlite-folder"
          task :setup_db do
            run "mkdir #{ sqlite_path }"
          end

          desc "save current db"
          task :save_db do
            if use_rvm
              run <<-CMD
                #{rvm_cmd} && 
                cd #{deploy_to}/current/db && 
                cp -f #{ sqlite_db }.sqlite3 #{ sqlite_path }/
              CMD
            else
              run "cd #{deploy_to}/current/db && cp #{ sqlite_db }.sqlite3 #{sqlite_path}/"
            end
          end

          desc "copy the database"
          task :copy_db do
            if use_rvm
              run <<-CMD
                #{rvm_cmd} && 
                cd #{sqlite_path} && 
                cp -f #{ sqlite_db }.sqlite3 #{deploy_to}/current/db/
              CMD
            else
              run "cd #{sqlite_path} && cp -f #{ sqlite_db }.sqlite3 #{deploy_to}/current/db/"
            end
          end

        end

        after "deploy:setup", "sqlite:setup_db"

        # eof
      end
    end
  end
end

Version data entries

27 entries across 27 versions & 1 rubygems

Version Path
magic_recipes-0.1.17 lib/magic_recipes/sqlite.rb
magic_recipes-0.1.16 lib/magic_recipes/sqlite.rb
magic_recipes-0.1.15 lib/magic_recipes/sqlite.rb
magic_recipes-0.1.14 lib/magic_recipes/sqlite.rb
magic_recipes-0.1.13 lib/magic_recipes/sqlite.rb
magic_recipes-0.1.11 lib/magic_recipes/sqlite.rb
magic_recipes-0.1.10 lib/magic_recipes/sqlite.rb
magic_recipes-0.1.9 lib/magic_recipes/sqlite.rb
magic_recipes-0.1.8 lib/magic_recipes/sqlite.rb
magic_recipes-0.1.7 lib/magic_recipes/sqlite.rb
magic_recipes-0.1.6 lib/magic_recipes/sqlite.rb
magic_recipes-0.1.5 lib/magic_recipes/sqlite.rb
magic_recipes-0.1.4 lib/magic_recipes/sqlite.rb
magic_recipes-0.1.3 lib/magic_recipes/sqlite.rb
magic_recipes-0.1.2 lib/magic_recipes/sqlite.rb
magic_recipes-0.1.1 lib/magic_recipes/sqlite.rb
magic_recipes-0.1.0 lib/magic_recipes/sqlite.rb
magic_recipes-0.0.29 lib/magic_recipes/sqlite.rb
magic_recipes-0.0.28 lib/magic_recipes/sqlite.rb
magic_recipes-0.0.27 lib/magic_recipes/sqlite.rb