activerecord-postgis-adapter 2.2.2 → 3.0.0.beta1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/active_record/connection_adapters/postgis_adapter.rb +2 -1
- data/lib/active_record/connection_adapters/postgis_adapter/arel_tosql.rb +9 -5
- data/lib/active_record/connection_adapters/postgis_adapter/create_connection.rb +7 -1
- data/lib/active_record/connection_adapters/postgis_adapter/main_adapter.rb +44 -185
- data/lib/active_record/connection_adapters/postgis_adapter/oid/spatial.rb +119 -0
- data/lib/active_record/connection_adapters/postgis_adapter/schema_statements.rb +110 -0
- data/lib/active_record/connection_adapters/postgis_adapter/spatial_column.rb +32 -122
- data/lib/active_record/connection_adapters/postgis_adapter/spatial_column_info.rb +2 -2
- data/lib/active_record/connection_adapters/postgis_adapter/spatial_table_definition.rb +115 -65
- data/lib/active_record/connection_adapters/postgis_adapter/version.rb +1 -1
- data/test/basic_test.rb +129 -159
- data/test/ddl_test.rb +240 -256
- data/test/nested_class_test.rb +7 -18
- data/test/spatial_queries_test.rb +67 -85
- data/test/tasks_test.rb +116 -117
- data/test/test_helper.rb +20 -0
- data/test/type_test.rb +26 -0
- metadata +33 -22
- data/lib/active_record/connection_adapters/postgis_adapter/common_adapter_methods.rb +0 -53
data/test/nested_class_test.rb
CHANGED
@@ -1,32 +1,21 @@
|
|
1
1
|
require 'test_helper'
|
2
2
|
|
3
3
|
class NestedClassTest < ActiveSupport::TestCase # :nodoc:
|
4
|
-
DATABASE_CONFIG_PATH = ::File.dirname(__FILE__) + '/database.yml'
|
5
|
-
OVERRIDE_DATABASE_CONFIG_PATH = ::File.dirname(__FILE__) + '/database_local.yml'
|
6
|
-
|
7
|
-
include RGeo::ActiveRecord::AdapterTestHelper
|
8
|
-
|
9
4
|
module Foo
|
10
5
|
def self.table_name_prefix
|
11
6
|
'foo_'
|
12
7
|
end
|
13
|
-
class Bar <
|
8
|
+
class Bar < ActiveRecord::Base
|
9
|
+
establish_connection YAML.load_file(ActiveSupport::TestCase::DATABASE_CONFIG_PATH)
|
14
10
|
end
|
15
11
|
end
|
16
12
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
Foo::Bar.class_eval do
|
21
|
-
establish_connection(DATABASE_CONFIG)
|
22
|
-
end
|
23
|
-
Foo::Bar.connection.create_table(:foo_bars) do |t|
|
24
|
-
t.column 'latlon', :point, :srid => 3785
|
25
|
-
end
|
26
|
-
Foo::Bar.all
|
27
|
-
Foo::Bar.connection.drop_table(:foo_bars)
|
13
|
+
def test_nested_model
|
14
|
+
Foo::Bar.connection.create_table(:foo_bars, force: true) do |t|
|
15
|
+
t.column 'latlon', :st_point, srid: 3785
|
28
16
|
end
|
29
|
-
|
17
|
+
assert_empty Foo::Bar.all
|
18
|
+
assert_equal 1, Foo::Bar.connection.drop_table(:foo_bars).result_status
|
30
19
|
end
|
31
20
|
|
32
21
|
end
|
@@ -1,97 +1,79 @@
|
|
1
1
|
require 'test_helper'
|
2
2
|
|
3
3
|
class SpatialQueriesTest < ActiveSupport::TestCase # :nodoc:
|
4
|
+
def test_query_point
|
5
|
+
create_model
|
6
|
+
obj = SpatialModel.new
|
7
|
+
obj.latlon = factory.point(1.0, 2.0)
|
8
|
+
obj.save!
|
9
|
+
id = obj.id
|
10
|
+
obj2 = SpatialModel.where(latlon: factory.multi_point([factory.point(1.0, 2.0)])).first
|
11
|
+
refute_nil(obj2)
|
12
|
+
assert_equal(id, obj2.id)
|
13
|
+
obj3 = SpatialModel.where(latlon: factory.point(2.0, 2.0)).first
|
14
|
+
assert_nil(obj3)
|
15
|
+
end
|
4
16
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
t.column 'latlon', :point, :srid => 3785
|
18
|
-
end
|
19
|
-
when :latlon_point_geographic
|
20
|
-
klass.connection.create_table(:spatial_test) do |t|
|
21
|
-
t.column 'latlon', :point, :srid => 4326, :geographic => true
|
22
|
-
end
|
23
|
-
when :path_linestring
|
24
|
-
klass.connection.create_table(:spatial_test) do |t|
|
25
|
-
t.column 'path', :line_string, :srid => 3785
|
26
|
-
end
|
27
|
-
end
|
28
|
-
klass
|
29
|
-
end
|
17
|
+
def test_query_point_wkt
|
18
|
+
create_model
|
19
|
+
obj = SpatialModel.new
|
20
|
+
obj.latlon = factory.point(1.0, 2.0)
|
21
|
+
obj.save!
|
22
|
+
id = obj.id
|
23
|
+
obj2 = SpatialModel.where(latlon: 'SRID=3785;POINT(1 2)').first
|
24
|
+
refute_nil(obj2)
|
25
|
+
assert_equal(id, obj2.id)
|
26
|
+
obj3 = SpatialModel.where(latlon: 'SRID=3785;POINT(2 2)').first
|
27
|
+
assert_nil(obj3)
|
28
|
+
end
|
30
29
|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
30
|
+
def test_query_st_distance
|
31
|
+
create_model
|
32
|
+
obj = SpatialModel.new
|
33
|
+
obj.latlon = factory.point(1.0, 2.0)
|
34
|
+
obj.save!
|
35
|
+
id = obj.id
|
36
|
+
obj2 = SpatialModel.where(SpatialModel.arel_table[:latlon].st_distance('SRID=3785;POINT(2 3)').lt(2)).first
|
37
|
+
refute_nil(obj2)
|
38
|
+
assert_equal(id, obj2.id)
|
39
|
+
obj3 = SpatialModel.where(SpatialModel.arel_table[:latlon].st_distance('SRID=3785;POINT(2 3)').gt(2)).first
|
40
|
+
assert_nil(obj3)
|
41
|
+
end
|
43
42
|
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
43
|
+
def test_query_st_distance_from_constant
|
44
|
+
create_model
|
45
|
+
obj = SpatialModel.new
|
46
|
+
obj.latlon = factory.point(1.0, 2.0)
|
47
|
+
obj.save!
|
48
|
+
id = obj.id
|
49
|
+
obj2 = SpatialModel.where(::Arel.spatial('SRID=3785;POINT(2 3)').st_distance(SpatialModel.arel_table[:latlon]).lt(2)).first
|
50
|
+
refute_nil(obj2)
|
51
|
+
assert_equal(id, obj2.id)
|
52
|
+
obj3 = SpatialModel.where(::Arel.spatial('SRID=3785;POINT(2 3)').st_distance(SpatialModel.arel_table[:latlon]).gt(2)).first
|
53
|
+
assert_nil(obj3)
|
54
|
+
end
|
56
55
|
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
56
|
+
def test_query_st_length
|
57
|
+
create_model
|
58
|
+
obj = SpatialModel.new
|
59
|
+
obj.path = factory.line(factory.point(1.0, 2.0), factory.point(3.0, 2.0))
|
60
|
+
obj.save!
|
61
|
+
id = obj.id
|
62
|
+
obj2 = SpatialModel.where(SpatialModel.arel_table[:path].st_length.eq(2)).first
|
63
|
+
refute_nil(obj2)
|
64
|
+
assert_equal(id, obj2.id)
|
65
|
+
obj3 = SpatialModel.where(SpatialModel.arel_table[:path].st_length.gt(3)).first
|
66
|
+
assert_nil(obj3)
|
67
|
+
end
|
69
68
|
|
70
|
-
|
71
|
-
klass = populate_ar_class(:mercator_point)
|
72
|
-
obj = klass.new
|
73
|
-
obj.latlon = @factory.point(1.0, 2.0)
|
74
|
-
obj.save!
|
75
|
-
id = obj.id
|
76
|
-
obj2 = klass.where(::Arel.spatial('SRID=3785;POINT(2 3)').st_distance(klass.arel_table[:latlon]).lt(2)).first
|
77
|
-
refute_nil(obj2)
|
78
|
-
assert_equal(id, obj2.id)
|
79
|
-
obj3 = klass.where(::Arel.spatial('SRID=3785;POINT(2 3)').st_distance(klass.arel_table[:latlon]).gt(2)).first
|
80
|
-
assert_nil(obj3)
|
81
|
-
end
|
69
|
+
private
|
82
70
|
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
obj.save!
|
88
|
-
id = obj.id
|
89
|
-
obj2 = klass.where(klass.arel_table[:path].st_length.eq(2)).first
|
90
|
-
refute_nil(obj2)
|
91
|
-
assert_equal(id, obj2.id)
|
92
|
-
obj3 = klass.where(klass.arel_table[:path].st_length.gt(3)).first
|
93
|
-
assert_nil(obj3)
|
71
|
+
def create_model
|
72
|
+
SpatialModel.connection.create_table(:spatial_models, force: true) do |t|
|
73
|
+
t.column 'latlon', :st_point, srid: 3785
|
74
|
+
t.column 'path', :line_string, srid: 3785
|
94
75
|
end
|
95
|
-
|
76
|
+
SpatialModel.reset_column_information
|
96
77
|
end
|
78
|
+
|
97
79
|
end
|
data/test/tasks_test.rb
CHANGED
@@ -2,157 +2,156 @@ require 'test_helper'
|
|
2
2
|
require 'active_record/schema_dumper'
|
3
3
|
|
4
4
|
class TasksTest < ActiveSupport::TestCase # :nodoc:
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
5
|
+
NEW_CONNECTION = {
|
6
|
+
"adapter" => "postgis",
|
7
|
+
"host" => "127.0.0.1",
|
8
|
+
"database" => "postgis_tasks_test",
|
9
|
+
"username" => "postgres",
|
10
|
+
"setup" => "default",
|
11
|
+
"schema_search_path" => "public",
|
12
|
+
}
|
13
|
+
|
14
|
+
def test_create_database_from_extension_in_public_schema
|
15
|
+
drop_db_if_exists
|
16
|
+
ActiveRecord::Tasks::DatabaseTasks.create(NEW_CONNECTION)
|
17
|
+
refute_empty connection.select_values("SELECT * from public.spatial_ref_sys")
|
14
18
|
end
|
15
19
|
|
16
|
-
|
20
|
+
def test_create_database_from_extension_in_separate_schema
|
21
|
+
drop_db_if_exists
|
22
|
+
configuration = NEW_CONNECTION.merge("postgis_schema" => "postgis")
|
23
|
+
ActiveRecord::Tasks::DatabaseTasks.create(configuration)
|
24
|
+
refute_empty connection.select_values("SELECT * from postgis.spatial_ref_sys")
|
25
|
+
end
|
17
26
|
|
18
|
-
def
|
19
|
-
|
20
|
-
|
21
|
-
|
27
|
+
def test_empty_sql_dump
|
28
|
+
setup_database_tasks
|
29
|
+
ActiveRecord::Tasks::DatabaseTasks.structure_dump(NEW_CONNECTION, tmp_sql_filename)
|
30
|
+
sql = File.read(tmp_sql_filename)
|
31
|
+
assert(sql !~ /CREATE TABLE/)
|
22
32
|
end
|
23
33
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
34
|
+
def test_basic_geography_sql_dump
|
35
|
+
setup_database_tasks
|
36
|
+
connection.create_table(:spatial_test, force: true) do |t|
|
37
|
+
t.st_point "latlon", geographic: true
|
28
38
|
end
|
39
|
+
ActiveRecord::Tasks::DatabaseTasks.structure_dump(NEW_CONNECTION, tmp_sql_filename)
|
40
|
+
data = File.read(tmp_sql_filename)
|
41
|
+
assert(data.index('latlon geography(Point,4326)'))
|
42
|
+
end
|
29
43
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
44
|
+
def test_index_sql_dump
|
45
|
+
setup_database_tasks
|
46
|
+
connection.create_table(:spatial_test, force: true) do |t|
|
47
|
+
t.st_point "latlon", geographic: true
|
48
|
+
t.string "name"
|
34
49
|
end
|
50
|
+
connection.add_index :spatial_test, :latlon, using: :gist
|
51
|
+
connection.add_index :spatial_test, :name, using: :btree
|
52
|
+
ActiveRecord::Tasks::DatabaseTasks.structure_dump(NEW_CONNECTION, tmp_sql_filename)
|
53
|
+
data = File.read(tmp_sql_filename)
|
54
|
+
assert(data.index('latlon geography(Point,4326)'))
|
55
|
+
assert data.index('CREATE INDEX index_spatial_test_on_latlon ON spatial_test USING gist (latlon);')
|
56
|
+
assert data.index('CREATE INDEX index_spatial_test_on_name ON spatial_test USING btree (name);')
|
57
|
+
end
|
35
58
|
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
assert(sql !~ /CREATE TABLE/)
|
59
|
+
def test_empty_schema_dump
|
60
|
+
setup_database_tasks
|
61
|
+
File.open(tmp_sql_filename, "w:utf-8") do |file|
|
62
|
+
ActiveRecord::SchemaDumper.dump(::ActiveRecord::Base.connection, file)
|
41
63
|
end
|
64
|
+
data = File.read(tmp_sql_filename)
|
65
|
+
assert(data.index('ActiveRecord::Schema'))
|
66
|
+
end
|
42
67
|
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
::ActiveRecord::Tasks::DatabaseTasks.structure_dump(TasksTest.new_database_config, tmp_sql_filename)
|
49
|
-
data = ::File.read(tmp_sql_filename)
|
50
|
-
assert(data.index('latlon geography(Point,4326)'))
|
68
|
+
def test_basic_geometry_schema_dump
|
69
|
+
setup_database_tasks
|
70
|
+
connection.create_table(:spatial_test, force: true) do |t|
|
71
|
+
t.geometry 'object1'
|
72
|
+
t.spatial "object2", srid: connection.default_srid, type: "geometry"
|
51
73
|
end
|
52
|
-
|
53
|
-
|
54
|
-
setup_database_tasks
|
55
|
-
connection.create_table(:spatial_test) do |t|
|
56
|
-
t.point "latlon", geographic: true
|
57
|
-
t.string "name"
|
58
|
-
end
|
59
|
-
connection.add_index :spatial_test, :latlon, spatial: true
|
60
|
-
connection.add_index :spatial_test, :name, using: :btree
|
61
|
-
::ActiveRecord::Tasks::DatabaseTasks.structure_dump(TasksTest.new_database_config, tmp_sql_filename)
|
62
|
-
data = ::File.read(tmp_sql_filename)
|
63
|
-
assert(data.index('latlon geography(Point,4326)'))
|
64
|
-
assert data.index('CREATE INDEX index_spatial_test_on_latlon ON spatial_test USING gist (latlon);')
|
65
|
-
assert data.index('CREATE INDEX index_spatial_test_on_name ON spatial_test USING btree (name);')
|
74
|
+
File.open(tmp_sql_filename, "w:utf-8") do |file|
|
75
|
+
ActiveRecord::SchemaDumper.dump(connection, file)
|
66
76
|
end
|
77
|
+
data = File.read(tmp_sql_filename)
|
78
|
+
assert data.index("t.geometry \"object1\", limit: {:srid=>#{connection.default_srid}, :type=>\"geometry\"")
|
79
|
+
assert data.index("t.geometry \"object2\", limit: {:srid=>#{connection.default_srid}, :type=>\"geometry\"")
|
80
|
+
end
|
67
81
|
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
data = ::File.read(tmp_sql_filename)
|
74
|
-
assert(data.index('ActiveRecord::Schema'))
|
82
|
+
def test_basic_geography_schema_dump
|
83
|
+
setup_database_tasks
|
84
|
+
connection.create_table(:spatial_test, force: true) do |t|
|
85
|
+
t.st_point "latlon1", geographic: true
|
86
|
+
t.spatial "latlon2", srid: 4326, type: "st_point", geographic: true
|
75
87
|
end
|
76
|
-
|
77
|
-
|
78
|
-
setup_database_tasks
|
79
|
-
connection.create_table(:spatial_test) do |t|
|
80
|
-
t.geometry 'object1'
|
81
|
-
t.spatial "object2", limit: { srid: connection.default_srid, type: "geometry" }
|
82
|
-
end
|
83
|
-
::File.open(tmp_sql_filename, "w:utf-8") do |file|
|
84
|
-
::ActiveRecord::SchemaDumper.dump(connection, file)
|
85
|
-
end
|
86
|
-
data = ::File.read(tmp_sql_filename)
|
87
|
-
assert(data.index("t.spatial \"object1\", limit: {:srid=>#{connection.default_srid}, :type=>\"geometry\"}"))
|
88
|
-
assert(data.index("t.spatial \"object2\", limit: {:srid=>#{connection.default_srid}, :type=>\"geometry\"}"))
|
88
|
+
File.open(tmp_sql_filename, "w:utf-8") do |file|
|
89
|
+
ActiveRecord::SchemaDumper.dump(connection, file)
|
89
90
|
end
|
91
|
+
data = File.read(tmp_sql_filename)
|
92
|
+
assert data.index(%(t.geography "latlon1", limit: {:srid=>4326, :type=>"point", :geographic=>true}))
|
93
|
+
assert data.index(%(t.geography "latlon2", limit: {:srid=>4326, :type=>"point", :geographic=>true}))
|
94
|
+
end
|
90
95
|
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
t.spatial "latlon2", limit: { srid: 4326, type: "point", geographic: true }
|
96
|
-
end
|
97
|
-
::File.open(tmp_sql_filename, "w:utf-8") do |file|
|
98
|
-
::ActiveRecord::SchemaDumper.dump(connection, file)
|
99
|
-
end
|
100
|
-
data = ::File.read(tmp_sql_filename)
|
101
|
-
assert(data.index('t.spatial "latlon1", limit: {:srid=>4326, :type=>"point", :geographic=>true}'))
|
102
|
-
assert(data.index('t.spatial "latlon2", limit: {:srid=>4326, :type=>"point", :geographic=>true}'))
|
96
|
+
def test_index_schema_dump
|
97
|
+
setup_database_tasks
|
98
|
+
connection.create_table(:spatial_test, force: true) do |t|
|
99
|
+
t.st_point "latlon", geographic: true
|
103
100
|
end
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
connection.create_table(:spatial_test) do |t|
|
108
|
-
t.point "latlon", geographic: true
|
109
|
-
end
|
110
|
-
connection.add_index :spatial_test, :latlon, spatial: true
|
111
|
-
::File.open(tmp_sql_filename, "w:utf-8") do |file|
|
112
|
-
::ActiveRecord::SchemaDumper.dump(connection, file)
|
113
|
-
end
|
114
|
-
data = ::File.read(tmp_sql_filename)
|
115
|
-
assert data.index('t.spatial "latlon", limit: {:srid=>4326, :type=>"point", :geographic=>true}')
|
116
|
-
assert data.index('add_index "spatial_test", ["latlon"], :name => "index_spatial_test_on_latlon", :spatial => true')
|
101
|
+
connection.add_index :spatial_test, :latlon, using: :gist
|
102
|
+
File.open(tmp_sql_filename, "w:utf-8") do |file|
|
103
|
+
ActiveRecord::SchemaDumper.dump(connection, file)
|
117
104
|
end
|
105
|
+
data = File.read(tmp_sql_filename)
|
106
|
+
assert data.index(%(t.geography "latlon", limit: {:srid=>4326, :type=>"point", :geographic=>true}))
|
107
|
+
assert data.index(%(add_index "spatial_test", ["latlon"], name: "index_spatial_test_on_latlon", using: :gist))
|
108
|
+
end
|
118
109
|
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
end
|
124
|
-
connection.add_index :test, :name, nil
|
125
|
-
::ActiveRecord::Tasks::DatabaseTasks.structure_dump(TasksTest.new_database_config, tmp_sql_filename)
|
126
|
-
data = ::File.read(tmp_sql_filename)
|
127
|
-
assert data.index('CREATE INDEX index_test_on_name ON test USING btree (name);')
|
110
|
+
def test_add_index_with_no_options
|
111
|
+
setup_database_tasks
|
112
|
+
connection.create_table(:test, force: true) do |t|
|
113
|
+
t.string "name"
|
128
114
|
end
|
115
|
+
connection.add_index :test, :name
|
116
|
+
ActiveRecord::Tasks::DatabaseTasks.structure_dump(NEW_CONNECTION, tmp_sql_filename)
|
117
|
+
data = File.read(tmp_sql_filename)
|
118
|
+
assert data.index('CREATE INDEX index_test_on_name ON test USING btree (name);')
|
119
|
+
end
|
129
120
|
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
end
|
136
|
-
::ActiveRecord::Tasks::DatabaseTasks.structure_dump(TasksTest.new_database_config, tmp_sql_filename)
|
137
|
-
data = ::File.read(tmp_sql_filename)
|
138
|
-
assert data.index('CREATE INDEX index_dogs_on_cats_id ON dogs USING btree (cats_id);')
|
121
|
+
def test_add_index_via_references
|
122
|
+
setup_database_tasks
|
123
|
+
connection.create_table(:cats, force: true)
|
124
|
+
connection.create_table(:dogs, force: true) do |t|
|
125
|
+
t.references :cats, index: true
|
139
126
|
end
|
127
|
+
ActiveRecord::Tasks::DatabaseTasks.structure_dump(NEW_CONNECTION, tmp_sql_filename)
|
128
|
+
data = File.read(tmp_sql_filename)
|
129
|
+
assert data.index('CREATE INDEX index_dogs_on_cats_id ON dogs USING btree (cats_id);')
|
140
130
|
end
|
141
131
|
|
142
132
|
private
|
143
133
|
|
144
134
|
def connection
|
145
|
-
|
135
|
+
ActiveRecord::Base.connection
|
146
136
|
end
|
147
137
|
|
148
138
|
def tmp_sql_filename
|
149
|
-
|
139
|
+
File.expand_path('../tmp/tmp.sql', ::File.dirname(__FILE__))
|
150
140
|
end
|
151
141
|
|
152
142
|
def setup_database_tasks
|
153
|
-
|
154
|
-
|
155
|
-
|
143
|
+
FileUtils.rm_f(tmp_sql_filename)
|
144
|
+
FileUtils.mkdir_p(::File.dirname(tmp_sql_filename))
|
145
|
+
drop_db_if_exists
|
146
|
+
ActiveRecord::ConnectionAdapters::PostGISAdapter::PostGISDatabaseTasks.new(NEW_CONNECTION).create
|
147
|
+
rescue ActiveRecord::Tasks::DatabaseAlreadyExists
|
148
|
+
# ignore
|
149
|
+
end
|
150
|
+
|
151
|
+
def drop_db_if_exists
|
152
|
+
ActiveRecord::ConnectionAdapters::PostGISAdapter::PostGISDatabaseTasks.new(NEW_CONNECTION).drop
|
153
|
+
rescue ActiveRecord::Tasks::DatabaseAlreadyExists
|
154
|
+
# ignore
|
156
155
|
end
|
157
156
|
|
158
157
|
end
|