Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions lib/capistrano-db-tasks/database.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,16 +44,15 @@ def dump_cmd
if mysql?
"mysqldump #{credentials} #{database} --lock-tables=false"
elsif postgresql?
"#{pgpass} pg_dump --no-acl --no-owner #{credentials} #{database}"
"#{pgpass} pg_dump --no-acl --no-owner -c #{credentials} #{database}"
end
end

def import_cmd(file)
if mysql?
"mysql #{credentials} -D #{database} < #{file}"
elsif postgresql?
terminate_connection_sql = "SELECT pg_terminate_backend(pg_stat_activity.pid) FROM pg_stat_activity WHERE pg_stat_activity.datname = '#{database}' AND pid <> pg_backend_pid();"
"#{pgpass} psql -c \"#{terminate_connection_sql};\" #{credentials}; #{pgpass} dropdb #{credentials} #{database}; #{pgpass} createdb #{credentials} #{database}; #{pgpass} psql #{credentials} -d #{database} < #{file}"
"#{pgpass} psql #{credentials} -d #{database} < #{file}"
end
end

Expand Down