Sha256: bfa3b6e424505e033eb031fcce730643367e15b850ac2fed7961db5a555eebb5

Contents?: true

Size: 797 Bytes

Versions: 2

Compression:

Stored size: 797 Bytes

Contents

module BaseBranch::Database::Adapter
  class Postgresql < Base
    class << self
      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

      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
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
base-branch-0.1.2 lib/base_branch/database/adapter/postgresql.rb
base-branch-0.1.1 lib/base_branch/database/adapter/postgresql.rb