Class: ActiveRecord::ConnectionAdapters::PostGIS::PostGISDatabaseTasks

Inherits:
Tasks::PostgreSQLDatabaseTasks
  • Object
show all
Defined in:
lib/active_record/connection_adapters/postgis/postgis_database_tasks.rb

Overview

:nodoc:

Instance Method Summary collapse

Constructor Details

#initialize(db_config) ⇒ PostGISDatabaseTasks

Returns a new instance of PostGISDatabaseTasks.


7
8
9
10
# File 'lib/active_record/connection_adapters/postgis/postgis_database_tasks.rb', line 7

def initialize(db_config)
  super
  ensure_installation_configs
end

Instance Method Details

#create(master_established = false) ⇒ Object

Override to set the database owner and call setup_gis


21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/active_record/connection_adapters/postgis/postgis_database_tasks.rb', line 21

def create(master_established = false)
  establish_master_connection unless master_established
  extra_configs = { encoding: encoding }
  extra_configs[:owner] = username if has_su?
  connection.create_database(db_config.database, configuration_hash.merge(extra_configs))
  setup_gis
rescue ::ActiveRecord::StatementInvalid => error
  if /database .* already exists/ === error.message
    raise ::ActiveRecord::DatabaseAlreadyExists
  else
    raise
  end
end

#setup_gisObject


12
13
14
15
16
17
18
# File 'lib/active_record/connection_adapters/postgis/postgis_database_tasks.rb', line 12

def setup_gis
  establish_su_connection
  if extension_names
    setup_gis_from_extension
  end
  establish_connection(db_config)
end