Sha256: 498c465564ac9d96535a2e266f9bc4d835be4f23589f39f40953e3032b4040bd

Contents?: true

Size: 1.19 KB

Versions: 2

Compression:

Stored size: 1.19 KB

Contents

require 'highline'

require_dependency 'schema_moves'
include SchemaMoves::Helpers

namespace :landable do
  namespace :data do
    desc 'Clean & restore database from specified source'
    task restore: ['db:drop', 'db:create', 'db:migrate', 'dump_and_load']

    desc 'Restore database from specified source'
    task dump_and_load: :environment do
      STDOUT.puts 'Enter Remote DB Host'
      host = STDIN.gets.strip

      STDOUT.puts 'Enter Remote Database'
      database = STDIN.gets.strip

      STDOUT.puts 'Enter Remote Username'
      username = STDIN.gets.strip

      `pg_dump -h #{host} -U #{username} --data-only --format plain --schema landable #{database} > landable_import.sql`
      `psql #{Rails.configuration.database_configuration[Rails.env]['database']} -f landable_import.sql`
      `rm landable_import.sql`
    end

    desc 'Migrates all to new schema'
    task move_schemas: :environment do
      get_schema_names
      create_schemas
      migrate_objects
      drop_old_schemas if want_to_drop_old_schemas?
    end

    desc 'Drop the old schemas'
    task drop_schemas: :environment do
      get_schema_names false
      drop_old_schemas if want_to_drop_old_schemas?
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
landable-1.14.0 lib/tasks/landable/data.rake
landable-1.13.2 lib/tasks/landable/data.rake