Sha256: 8cd760bc16bfc920afea53272eea5f3560b2f301446760cf587f3156a69d2a49

Contents?: true

Size: 795 Bytes

Versions: 1

Compression:

Stored size: 795 Bytes

Contents

if File.exist? Rails.root.join('config/database.yml')
  namespace :postgresql do
    config = YAML.load(File.read(Rails.root.join('config/database.yml')))[Rails.env.to_s]
    if config['adapter'] == 'postgresql'
      db = config['database']
      host = config['host']
      user = config['username']
      password = config['password']
      FileUtils.mkdir_p Rails.root.join('postgresql')

      backup = "pg_dump -h #{host} -d #{db} -U #{user} -F t -f #{Rails.root}/postgresql/dump.tar"
      desc backup
      task :dump do
        zfben_rails_rake_system backup
      end

      restore = "pg_restore -h #{host} -U #{user} -c -f #{Rails.root}/postgresql/dump.tar"
      desc restore
      task :restore => 'db:create' do
        zfben_rails_rake_system restore
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
h2ocube_rails_tasks-0.0.8 lib/h2ocube_rails_tasks/tasks/postgresql.rb