Module: PostgreSQLMethods
- Defined in:
- lib/railsmachine/recipes/db/postgresql.rb
Instance Method Summary collapse
Instance Method Details
#command(sql, database) ⇒ Object
33 34 35 |
# File 'lib/railsmachine/recipes/db/postgresql.rb', line 33 def command(sql, database) run "psql --command=\"#{sql}\" #{database}" end |
#createdb(db, user) ⇒ Object
17 18 19 |
# File 'lib/railsmachine/recipes/db/postgresql.rb', line 17 def createdb(db, user) run "createdb -O #{user} #{db}" end |
#createuser(user, password) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/railsmachine/recipes/db/postgresql.rb', line 21 def createuser(user, password) cmd = "createuser -P -D -A -E #{user}" run cmd do |channel, stream, data| if data =~ /^Enter password for new user:/ channel.send_data "#{password}\n" end if data =~ /^Enter it again:/ channel.send_data "#{password}\n" end end end |