Class: RailsInstaller::Database::Postgresql
- Inherits:
-
RailsInstaller::Database
- Object
- RailsInstaller::Database
- RailsInstaller::Database::Postgresql
- Defined in:
- lib/rails-installer/databases.rb
Overview
A PostgreSQL driver. This is a bit more work then the SQLite driver, as Postgres needs to talk to its server. So it takes a number of config variables:
* db_host
* db_name
* db_user
* db_password
It will call createdb
to set up the db all on its own.
Class Method Summary collapse
-
.create_database(installer) ⇒ Object
Create a PostgreSQL database.
- .yml(installer) ⇒ Object
Methods inherited from RailsInstaller::Database
backup, connect, create, database_yml, db_host, db_name, db_user, dbs, inherited, restore
Class Method Details
.create_database(installer) ⇒ Object
Create a PostgreSQL database.
224 225 226 227 228 |
# File 'lib/rails-installer/databases.rb', line 224 def self.create_database(installer) installer. "Creating PostgreSQL database" system("createdb -U #{db_user installer} #{db_name installer}") system("createdb -U #{db_user installer} #{db_name installer}-test") end |
.yml(installer) ⇒ Object
202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 |
# File 'lib/rails-installer/databases.rb', line 202 def self.yml(installer) %Q{ login: &login adapter: postgresql host: #{db_host installer} username: #{db_user installer} password: #{installer.config['db_password']} database: #{db_name installer} development: <<: *login production: <<: *login test: database: #{db_name installer}-test <<: *login } end |