Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change dump (with clean flag) and import method for psql #29

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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