# REQUIRED: The credentials for creating/accessing your app's database
#
db_user: "#{app_name[0,16].downcase}"
db_pass:
db_name: "#{app_name.downcase}_#{Rubber.env}"

db_replication_user: replication
db_replication_pass:
postgresql_synchronous_replication: false

# REQUIRED: The command to use to do a full backup of your database using
#           "rubber util:backup_db"
db_backup_cmd: "set -e -o pipefail; nice sudo -u postgres pg_dumpall -U postgres | gzip -c > %backup_file%"

# REQUIRED: The command to use to restore the database using
#           "rake util:restore_db"
#           This command will receive the data generated by db_backup_cmd via
#           its standard input
db_restore_cmd: "zcat - | psql -U %user% -h %host% %name%"

postgresql_ver: 9.3
postgresql_conf_dir: "/etc/postgresql/#{postgresql_ver}/main"
postgresql_data_dir: "/mnt/postgresql/#{postgresql_ver}/data"
postgresql_archive_dir: "/mnt/postgresql/#{postgresql_ver}/archive"
postgresql_pid_file: "/var/run/postgresql/#{postgresql_ver}-main.pid"
postgresql_ctl: "/usr/bin/env service postgresql"

# Capistrano needs db:primary role for migrate to work,
# so we might as well just make consistent across the board
role_dependencies:
  postgresql_master: [postgresql, "db:primary=true"]
  postgresql_slave: [postgresql, db]
  "db:primary=true": [postgresql, postgresql_master]
  db: [postgresql, postgresql_slave]

packages: ["postgresql-client-#{postgresql_ver}", libpq-dev]
gems: [pg]

roles:
  postgresql_master:
    db_server_id: 1
  postgresql_slave:
    db_server_id: 2
  db:
    packages: ["postgresql-#{postgresql_ver}"]
