magic_recipes 0.0.22 → 0.0.23

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 +21 -2
  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 a database for this application.
10
+ # :create_database # => Create postgres database and user for this application.
11
11
  #
12
12
  # :setup # => Generate the database.yml configuration file.
13
13
  #
@@ -17,6 +17,12 @@ module MagicRecipes
17
17
  #
18
18
  # :drop_public_shema # => drop public shema so db is empty and not dropped
19
19
  #
20
+ # :create_user # => Create a postgres-user for this application.
21
+ #
22
+ # :drop_user # => Drop the postgres-user for this application.
23
+ #
24
+ # :drop_database # => Drop the postgres-database for this application.
25
+ #
20
26
  # [Callbacks:]
21
27
  # after "deploy:install", "postgresql:install"
22
28
  #
@@ -52,7 +58,8 @@ module MagicRecipes
52
58
  #run %Q{#{sudo} -u postgres psql -c "create user #{postgresql_user} with password '#{postgresql_password}';"}
53
59
  # make a superuser .. to be able to install extensions like hstore
54
60
  run %Q{#{sudo} -u postgres psql -c "CREATE ROLE #{postgresql_user} WITH SUPERUSER CREATEDB CREATEROLE LOGIN ENCRYPTED PASSWORD '#{postgresql_password}';"}
55
- run %Q{#{sudo} -u postgres psql -c "create database #{postgresql_database} owner #{postgresql_user};"}
61
+ #run %Q{#{sudo} -u postgres psql -c "create database #{postgresql_database} owner #{postgresql_user};"}
62
+ run %Q{#{sudo} -u postgres psql -c "CREATE DATABASE #{postgresql_database} WITH OWNER #{postgresql_user} ENCODING 'UTF8';"}
56
63
  end
57
64
  after "deploy:setup", "postgresql:create_database"
58
65
 
@@ -62,6 +69,18 @@ module MagicRecipes
62
69
  run %Q{#{sudo} -u postgres psql -c "CREATE ROLE #{postgresql_user} WITH SUPERUSER CREATEDB CREATEROLE LOGIN ENCRYPTED PASSWORD '#{postgresql_password}';"}
63
70
  end
64
71
 
72
+ desc "Drop the postgres-user for this application."
73
+ task :drop_user, roles: :db, only: {primary: true} do
74
+ # make a superuser .. to be able to install extensions like hstore
75
+ run %Q{#{sudo} -u postgres psql -c "DROP ROLE #{postgresql_user};"}
76
+ end
77
+
78
+ desc "Drop the postgres-database for this application."
79
+ task :drop_database, roles: :db, only: {primary: true} do
80
+ # make a superuser .. to be able to install extensions like hstore
81
+ run %Q{#{sudo} -u postgres psql -c "DROP DATABASE #{postgresql_database};"}
82
+ end
83
+
65
84
  desc "Generate the database.yml configuration file."
66
85
  task :setup, roles: :app do
67
86
  run "mkdir -p #{shared_path}/config"
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.22
4
+ version: 0.0.23
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: