Class: BaseBranch::Database::Adapter::Postgresql
- Inherits:
-
Base
- Object
- Base
- BaseBranch::Database::Adapter::Postgresql
show all
- Defined in:
- lib/base_branch/database/adapter/postgresql.rb
Class Method Summary
collapse
Methods inherited from Base
orm_execute, orm_sanitize, orm_successfully_executed?
Class Method Details
.clone_db(db_name, from_db, db_user) ⇒ Object
4
5
6
7
8
9
10
11
12
13
14
15
16
17
|
# File 'lib/base_branch/database/adapter/postgresql.rb', line 4
def clone_db(db_name, from_db, db_user)
result = if db_user
orm_execute <<-SQL
CREATE DATABASE "#{db_name}" WITH TEMPLATE "#{from_db}" OWNER #{db_user};
SQL
else
orm_execute <<-SQL
CREATE DATABASE "#{db_name}" WITH TEMPLATE "#{from_db}";
SQL
end
orm_successfully_executed? result
end
|
.db_present?(db_name) ⇒ Boolean
19
20
21
22
23
24
25
26
|
# File 'lib/base_branch/database/adapter/postgresql.rb', line 19
def db_present?(db_name)
field_name = orm_sanitize db_name
result = orm_execute <<-SQL
SELECT 1 from pg_database WHERE datname=#{field_name};
SQL
result.count > 0
end
|