Sha256: b03abcb9657a198ede8219e80acdd1ebe3b729d9246b5a491eb61759e81c5204

Contents?: true

Size: 985 Bytes

Versions: 1

Compression:

Stored size: 985 Bytes

Contents

require "backhoe"
require "bard-backup"

namespace :db do
  desc "Dump the current database to supplied path (default: db/data.sql.gz)"
  task :dump, [:path] => :environment do |_, args|
    args.with_defaults(path: "db/data.sql.gz")
    Backhoe.dump args.path
  end

  desc "Load the supplied path (default: db/data.sql.gz) into the current database."
  task :load, [:path] => :environment do |_, args|
    args.with_defaults(path: "db/data.sql.gz")
    Backhoe.load args.path, drop_and_create: true
  end

  task :backup => :environment do
    project_name = File.basename(Dir.getwd)
    config = Rails.application.credentials.bard_backup
    s3_path = config.delete(:s3_path) || "bard-backup/#{project_name}"
    Bard::Backup.call s3_path, **config
  end

  task "drop:current" => :environment do
    ActiveRecord::Tasks::DatabaseTasks.drop Rails.env.to_sym
  end

  task "create:current" => :environment do
    ActiveRecord::Tasks::DatabaseTasks.create Rails.env.to_sym
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
bard-rake-0.24.0 lib/bard/rake/db_dump_load.rb