lib/magic_recipes/postgresql.rb in magic_recipes-0.0.21 vs lib/magic_recipes/postgresql.rb in magic_recipes-0.0.22
- old
+ new
@@ -45,15 +45,23 @@
run "#{sudo} apt-get -y update"
run "#{sudo} apt-get -y install postgresql libpq-dev"
end
after "deploy:install", "postgresql:install"
- desc "Create a database for this application."
+ desc "Create a database and user for this application."
task :create_database, roles: :db, only: {primary: true} do
- run %Q{#{sudo} -u postgres psql -c "create user #{postgresql_user} with password '#{postgresql_password}';"}
+ #run %Q{#{sudo} -u postgres psql -c "create user #{postgresql_user} with password '#{postgresql_password}';"}
+ # make a superuser .. to be able to install extensions like hstore
+ run %Q{#{sudo} -u postgres psql -c "CREATE ROLE #{postgresql_user} WITH SUPERUSER CREATEDB CREATEROLE LOGIN ENCRYPTED PASSWORD '#{postgresql_password}';"}
run %Q{#{sudo} -u postgres psql -c "create database #{postgresql_database} owner #{postgresql_user};"}
end
after "deploy:setup", "postgresql:create_database"
+
+ desc "Create a postgres-user for this application."
+ task :create_user, roles: :db, only: {primary: true} do
+ # make a superuser .. to be able to install extensions like hstore
+ run %Q{#{sudo} -u postgres psql -c "CREATE ROLE #{postgresql_user} WITH SUPERUSER CREATEDB CREATEROLE LOGIN ENCRYPTED PASSWORD '#{postgresql_password}';"}
+ end
desc "Generate the database.yml configuration file."
task :setup, roles: :app do
run "mkdir -p #{shared_path}/config"
template "postgresql.yml.erb", "#{shared_path}/config/postgres_#{rails_env}.yml"
\ No newline at end of file