magic_recipes 0.0.24 → 0.0.25

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. data/lib/magic_recipes/postgresql.rb +10 -3
  2. metadata +1 -1
@@ -7,7 +7,7 @@ module MagicRecipes
7
7
  # [Tasks:]
8
8
  # :install # => Install the latest stable release of PostgreSQL.
9
9
  #
10
- # :create_database # => Create postgres database and user for this application.
10
+ # :create_database # => Create database and user for this application.
11
11
  #
12
12
  # :setup # => Generate the database.yml configuration file.
13
13
  #
@@ -21,6 +21,8 @@ module MagicRecipes
21
21
  #
22
22
  # :drop_user # => Drop the postgres-user for this application.
23
23
  #
24
+ # :create_db # => Create only a database for this application.
25
+ #
24
26
  # :drop_database # => Drop the postgres-database for this application.
25
27
  #
26
28
  # [Callbacks:]
@@ -50,12 +52,13 @@ module MagicRecipes
50
52
  run "#{sudo} add-apt-repository ppa:pitti/postgresql"
51
53
  run "#{sudo} apt-get -y update"
52
54
  run "#{sudo} apt-get -y install postgresql libpq-dev"
55
+ # add constrib for hstore extension
56
+ run "#{sudo} apt-get -y install postgresql-contrib-9.1"
53
57
  end
54
58
  after "deploy:install", "postgresql:install"
55
59
 
56
60
  desc "Create a database and user for this application."
57
61
  task :create_database, roles: :db, only: {primary: true} do
58
- #run %Q{#{sudo} -u postgres psql -c "create user #{postgresql_user} with password '#{postgresql_password}';"}
59
62
  # make a superuser .. to be able to install extensions like hstore
60
63
  run %Q{#{sudo} -u postgres psql -c "CREATE ROLE #{postgresql_user} WITH SUPERUSER CREATEDB CREATEROLE LOGIN ENCRYPTED PASSWORD '#{postgresql_password}';"}
61
64
  #run %Q{#{sudo} -u postgres psql -c "create database #{postgresql_database} owner #{postgresql_user};"}
@@ -75,6 +78,11 @@ module MagicRecipes
75
78
  run %Q{#{sudo} -u postgres psql -c "DROP ROLE #{postgresql_user};"}
76
79
  end
77
80
 
81
+ desc "Create only a database for this application."
82
+ task :create_db, roles: :db, only: {primary: true} do
83
+ run %Q{#{sudo} -u postgres psql -c "CREATE DATABASE #{postgresql_database} WITH OWNER #{postgresql_user};"}
84
+ end
85
+
78
86
  desc "Drop the postgres-database for this application."
79
87
  task :drop_database, roles: :db, only: {primary: true} do
80
88
  # make a superuser .. to be able to install extensions like hstore
@@ -97,7 +105,6 @@ module MagicRecipes
97
105
  # http://stackoverflow.com/a/12939218/1470996
98
106
  desc 'kill pgsql users so database can be dropped'
99
107
  task :kill_postgres_connections do
100
- # run "echo 'SELECT pg_terminate_backend(procpid) FROM pg_stat_activity WHERE datname=\'#{postgresql_database}\';' | psql -U postgres"
101
108
  run %Q{#{sudo} -u postgres psql -c "SELECT pg_terminate_backend(procpid) FROM pg_stat_activity WHERE datname='#{postgresql_database}';"}
102
109
  end
103
110
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: magic_recipes
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.24
4
+ version: 0.0.25
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: