activerecord-postgis-adapter 7.1.0 → 8.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: fcaaf2a57395c122e6541b1e40bd416f5f31fd1e512c250e5222ec5bb3feb650
4
- data.tar.gz: 2772452b3ea880ecab759cb5add73d2ed22a89a78e12eae087aff60a061a8f20
3
+ metadata.gz: d0e36778a7f367dc3b7477d7f389d94360b0f9130791cea0120b81f0feef745b
4
+ data.tar.gz: 29d1233c9abbd1bbf0b0325310acb5a23eca2ba9baab7756729c2ea2bf6d14ec
5
5
  SHA512:
6
- metadata.gz: 743b335ad32f5d872eebd7c512d7557102ed137664e4336a8c26154fe5f3b2bc3ded2b8e0ebe73195e05e8bb9affb538f7dde93e2aa095b142078e464c2fed98
7
- data.tar.gz: 8cfc035141871044857863337a94f4c854423afc784f305853cd1a838dde14ec729a941c50a14edc5841829e8c21ce8c4f04c1826611ecb853d8239fb95401f4
6
+ metadata.gz: ce7fda2c1d2baa1a4ab7ba120ad643468e12ed68b7e7100e5a1ef002e803fac5c8b764514d108986942e41729809b24ef31e7a6b75b14658bfe6bbb5e5407fad
7
+ data.tar.gz: 7e7d8e706991da86fb963735a67f1f28a9e97d258bf1fe099d6f61f449e0f16064909f2a96614fa8737e87cd31c2f99c3982d8d5e6da782f29a3a01bfbc6886b
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ActiveRecord
4
+ module ConnectionAdapters # :nodoc:
5
+ module PostGIS
6
+ module DatabaseStatements
7
+ def truncate_tables(*table_names)
8
+ table_names -= ["spatial_ref_sys"]
9
+ super(*table_names)
10
+ end
11
+ end
12
+ end
13
+ end
14
+ end
@@ -9,7 +9,7 @@ module ActiveRecord
9
9
  # Accepts `geo_type`, `srid`, `has_z`, `has_m`, and `geographic` as parameters.
10
10
  # Responsible for parsing sql_types returned from the database and WKT features.
11
11
  class Spatial < Type::Value
12
- def initialize(geo_type: 'geometry', srid: 0, has_z: false, has_m: false, geographic: false)
12
+ def initialize(geo_type: "geometry", srid: 0, has_z: false, has_m: false, geographic: false)
13
13
  @geo_type = geo_type
14
14
  @srid = srid
15
15
  @has_z = has_z
@@ -5,18 +5,17 @@ module ActiveRecord
5
5
  module PostGIS
6
6
  module SchemaStatements
7
7
  # override
8
- # https://github.com/rails/rails/blob/6-0-stable/activerecord/lib/active_record/connection_adapters/postgresql/schema_statements.rb#L624
8
+ # https://github.com/rails/rails/blob/7-0-stable/activerecord/lib/active_record/connection_adapters/postgresql/schema_statements.rb#L662
9
9
  # Create a SpatialColumn instead of a PostgreSQL::Column
10
10
  def new_column_from_field(table_name, field)
11
- column_name, type, default, notnull, oid, fmod, collation, comment = field
11
+ column_name, type, default, notnull, oid, fmod, collation, comment, attgenerated = field
12
12
  type_metadata = fetch_type_metadata(column_name, type, oid.to_i, fmod.to_i)
13
13
  default_value = extract_value_from_default(default)
14
14
  default_function = extract_default_function(default_value, default)
15
15
 
16
- serial =
17
- if (match = default_function&.match(/\Anextval\('"?(?<sequence_name>.+_(?<suffix>seq\d*))"?'::regclass\)\z/))
18
- sequence_name_from_parts(table_name, column_name, match[:suffix]) == match[:sequence_name]
19
- end
16
+ if match = default_function&.match(/\Anextval\('"?(?<sequence_name>.+_(?<suffix>seq\d*))"?'::regclass\)\z/)
17
+ serial = sequence_name_from_parts(table_name, column_name, match[:suffix]) == match[:sequence_name]
18
+ end
20
19
 
21
20
  # {:dimension=>2, :has_m=>false, :has_z=>false, :name=>"latlon", :srid=>0, :type=>"GEOMETRY"}
22
21
  spatial = spatial_column_info(table_name).get(column_name, type_metadata.sql_type)
@@ -30,49 +29,11 @@ module ActiveRecord
30
29
  collation: collation,
31
30
  comment: comment.presence,
32
31
  serial: serial,
32
+ generated: attgenerated,
33
33
  spatial: spatial
34
34
  )
35
35
  end
36
36
 
37
- # override
38
- # https://github.com/rails/rails/blob/master/activerecord/lib/active_record/connection_adapters/postgresql/schema_statements.rb#L544
39
- #
40
- # returns Postgresql sql type string
41
- # examples:
42
- # "geometry(Point,4326)"
43
- # "geography(Point,4326)"
44
- #
45
- # note: type alone is not enough to detect the sql type,
46
- # so `limit` is used to pass the additional information. :(
47
- #
48
- # type_to_sql(:geography, limit: "Point,4326")
49
- # => "geography(Point,4326)"
50
- def type_to_sql(type, limit: nil, precision: nil, scale: nil, array: nil, **)
51
- case type.to_s
52
- when "geometry", "geography"
53
- "#{type}(#{limit})"
54
- else
55
- super
56
- end
57
- end
58
-
59
- # override
60
- def native_database_types
61
- # Add spatial types
62
- super.merge(
63
- geography: { name: "geography" },
64
- geometry: { name: "geometry" },
65
- geometry_collection: { name: "geometry_collection" },
66
- line_string: { name: "line_string" },
67
- multi_line_string: { name: "multi_line_string" },
68
- multi_point: { name: "multi_point" },
69
- multi_polygon: { name: "multi_polygon" },
70
- spatial: { name: "geometry" },
71
- st_point: { name: "st_point" },
72
- st_polygon: { name: "st_polygon" }
73
- )
74
- end
75
-
76
37
  # override
77
38
  def create_table_definition(*args, **kwargs)
78
39
  PostGIS::TableDefinition.new(self, *args, **kwargs)
@@ -83,33 +44,6 @@ module ActiveRecord
83
44
  @spatial_column_info ||= {}
84
45
  @spatial_column_info[table_name.to_sym] ||= SpatialColumnInfo.new(self, table_name.to_s)
85
46
  end
86
-
87
- def initialize_type_map(map = type_map)
88
- %w(
89
- geography
90
- geometry
91
- geometry_collection
92
- line_string
93
- multi_line_string
94
- multi_point
95
- multi_polygon
96
- st_point
97
- st_polygon
98
- ).each do |geo_type|
99
- map.register_type(geo_type) do |_, _, sql_type|
100
- # sql_type is a string that comes from the database definition
101
- # examples:
102
- # "geometry(Point,4326)"
103
- # "geography(Point,4326)"
104
- # "geometry(Polygon,4326) NOT NULL"
105
- # "geometry(Geography,4326)"
106
- geo_type, srid, has_z, has_m, geographic = OID::Spatial.parse_sql_type(sql_type)
107
- OID::Spatial.new(geo_type: geo_type, srid: srid, has_z: has_z, has_m: has_m, geographic: geographic)
108
- end
109
- end
110
-
111
- super
112
- end
113
47
  end
114
48
  end
115
49
  end
@@ -9,7 +9,7 @@ module ActiveRecord # :nodoc:
9
9
  # "Geography(Point,4326)"
10
10
  def initialize(name, default, sql_type_metadata = nil, null = true,
11
11
  default_function = nil, collation: nil, comment: nil,
12
- serial: nil, spatial: nil)
12
+ serial: nil, generated: nil, spatial: nil)
13
13
  @sql_type_metadata = sql_type_metadata
14
14
  @geographic = !!(sql_type_metadata.sql_type =~ /geography\(/i)
15
15
  if spatial
@@ -31,14 +31,12 @@ module ActiveRecord # :nodoc:
31
31
  build_from_sql_type(sql_type_metadata.sql_type)
32
32
  end
33
33
  super(name, default, sql_type_metadata, null, default_function,
34
- collation: collation, comment: comment, serial: serial)
35
- if spatial?
36
- if @srid
37
- @limit = { srid: @srid, type: to_type_name(geometric_type) }
38
- @limit[:has_z] = true if @has_z
39
- @limit[:has_m] = true if @has_m
40
- @limit[:geographic] = true if @geographic
41
- end
34
+ collation: collation, comment: comment, serial: serial, generated: generated)
35
+ if spatial? && @srid
36
+ @limit = { srid: @srid, type: to_type_name(geometric_type) }
37
+ @limit[:has_z] = true if @has_z
38
+ @limit[:has_m] = true if @has_m
39
+ @limit[:geographic] = true if @geographic
42
40
  end
43
41
  end
44
42
 
@@ -73,9 +71,10 @@ module ActiveRecord # :nodoc:
73
71
 
74
72
  def to_type_name(geometric_type)
75
73
  name = geometric_type.type_name.underscore
76
- if name == "point"
74
+ case name
75
+ when "point"
77
76
  "st_point"
78
- elsif name == "polygon"
77
+ when "polygon"
79
78
  "st_polygon"
80
79
  else
81
80
  name
@@ -21,7 +21,7 @@ module ActiveRecord # :nodoc:
21
21
  dimension = row[1].to_i
22
22
  has_m = !!(type =~ /m$/i)
23
23
  type.sub!(/m$/, "")
24
- has_z = dimension > 3 || dimension == 3 && !has_m
24
+ has_z = dimension > 3 || (dimension == 3 && !has_m)
25
25
  result[name] = {
26
26
  dimension: dimension,
27
27
  has_m: has_m,
@@ -9,8 +9,8 @@ module ActiveRecord # :nodoc:
9
9
  # super: https://github.com/rails/rails/blob/master/activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb
10
10
  def new_column_definition(name, type, **options)
11
11
  if (info = PostGISAdapter.spatial_column_options(type.to_sym))
12
- if (limit = options.delete(:limit))
13
- options.merge!(limit) if limit.is_a?(::Hash)
12
+ if (limit = options.delete(:limit)) && limit.is_a?(::Hash)
13
+ options.merge!(limit)
14
14
  end
15
15
 
16
16
  geo_type = ColumnDefinitionUtils.geo_type(options[:type] || type || info[:type])
@@ -3,7 +3,7 @@
3
3
  module ActiveRecord
4
4
  module ConnectionAdapters
5
5
  module PostGIS
6
- VERSION = "7.1.0"
6
+ VERSION = "8.0.1"
7
7
  end
8
8
  end
9
9
  end
@@ -12,22 +12,14 @@ require "active_record/connection_adapters/postgresql_adapter"
12
12
  require "active_record/connection_adapters/postgis/version"
13
13
  require "active_record/connection_adapters/postgis/column_methods"
14
14
  require "active_record/connection_adapters/postgis/schema_statements"
15
+ require "active_record/connection_adapters/postgis/database_statements"
15
16
  require "active_record/connection_adapters/postgis/spatial_column_info"
16
17
  require "active_record/connection_adapters/postgis/spatial_table_definition"
17
18
  require "active_record/connection_adapters/postgis/spatial_column"
18
19
  require "active_record/connection_adapters/postgis/arel_tosql"
19
- require "active_record/connection_adapters/postgis/setup"
20
20
  require "active_record/connection_adapters/postgis/oid/spatial"
21
21
  require "active_record/connection_adapters/postgis/type" # has to be after oid/*
22
22
  require "active_record/connection_adapters/postgis/create_connection"
23
- require "active_record/connection_adapters/postgis/postgis_database_tasks"
24
-
25
- ActiveRecord::ConnectionAdapters::PostGIS.initial_setup
26
-
27
- if defined?(Rails::Railtie)
28
- require "active_record/connection_adapters/postgis/railtie"
29
- end
30
-
31
23
  # :startdoc:
32
24
 
33
25
  module ActiveRecord
@@ -53,6 +45,7 @@ module ActiveRecord
53
45
  DEFAULT_SRID = 0
54
46
 
55
47
  include PostGIS::SchemaStatements
48
+ include PostGIS::DatabaseStatements
56
49
 
57
50
  def arel_visitor # :nodoc:
58
51
  Arel::Visitors::PostGIS.new(self)
@@ -70,6 +63,53 @@ module ActiveRecord
70
63
  DEFAULT_SRID
71
64
  end
72
65
 
66
+ class << self
67
+ def initialize_type_map(map = type_map)
68
+ %w[
69
+ geography
70
+ geometry
71
+ geometry_collection
72
+ line_string
73
+ multi_line_string
74
+ multi_point
75
+ multi_polygon
76
+ st_point
77
+ st_polygon
78
+ ].each do |geo_type|
79
+ map.register_type(geo_type) do |_, _, sql_type|
80
+ # sql_type is a string that comes from the database definition
81
+ # examples:
82
+ # "geometry(Point,4326)"
83
+ # "geography(Point,4326)"
84
+ # "geometry(Polygon,4326) NOT NULL"
85
+ # "geometry(Geography,4326)"
86
+ geo_type, srid, has_z, has_m, geographic = PostGIS::OID::Spatial.parse_sql_type(sql_type)
87
+ PostGIS::OID::Spatial.new(geo_type: geo_type, srid: srid, has_z: has_z, has_m: has_m, geographic: geographic)
88
+ end
89
+ end
90
+
91
+ super
92
+ end
93
+
94
+ def native_database_types
95
+ @native_database_types ||= begin
96
+ default_types = PostgreSQLAdapter.native_database_types
97
+ default_types.merge({
98
+ geography: { name: "geography" },
99
+ geometry: { name: "geometry" },
100
+ geometry_collection: { name: "geometry_collection" },
101
+ line_string: { name: "line_string" },
102
+ multi_line_string: { name: "multi_line_string" },
103
+ multi_point: { name: "multi_point" },
104
+ multi_polygon: { name: "multi_polygon" },
105
+ spatial: { name: "geometry" },
106
+ st_point: { name: "st_point" },
107
+ st_polygon: { name: "st_polygon" }
108
+ })
109
+ end
110
+ end
111
+ end
112
+
73
113
  def srs_database_columns
74
114
  {
75
115
  auth_name_column: "auth_name",
@@ -89,6 +129,14 @@ module ActiveRecord
89
129
  end
90
130
  end
91
131
 
132
+ def quote_default_expression(value, column)
133
+ if column.type == :geography || column.type == :geometry
134
+ quote(value)
135
+ else
136
+ super
137
+ end
138
+ end
139
+
92
140
  # PostGIS specific types
93
141
  [
94
142
  :geography,
@@ -105,6 +153,16 @@ module ActiveRecord
105
153
  end
106
154
  end
107
155
  end
156
+ SchemaDumper.ignore_tables |= %w[
157
+ geography_columns
158
+ geometry_columns
159
+ layer
160
+ raster_columns
161
+ raster_overviews
162
+ spatial_ref_sys
163
+ topology
164
+ ]
165
+ Tasks::DatabaseTasks.register_task(/postgis/, "ActiveRecord::Tasks::PostgreSQLDatabaseTasks")
108
166
  end
109
167
 
110
168
  # if using JRUBY, create ArJdbc::PostGIS module
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activerecord-postgis-adapter
3
3
  version: !ruby/object:Gem::Version
4
- version: 7.1.0
4
+ version: 8.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Azuma
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2021-03-28 00:00:00.000000000 Z
12
+ date: 2022-08-01 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activerecord
@@ -17,14 +17,14 @@ dependencies:
17
17
  requirements:
18
18
  - - "~>"
19
19
  - !ruby/object:Gem::Version
20
- version: '6.1'
20
+ version: 7.0.0
21
21
  type: :runtime
22
22
  prerelease: false
23
23
  version_requirements: !ruby/object:Gem::Requirement
24
24
  requirements:
25
25
  - - "~>"
26
26
  - !ruby/object:Gem::Version
27
- version: '6.1'
27
+ version: 7.0.0
28
28
  - !ruby/object:Gem::Dependency
29
29
  name: rgeo-activerecord
30
30
  requirement: !ruby/object:Gem::Requirement
@@ -45,14 +45,14 @@ dependencies:
45
45
  requirements:
46
46
  - - "~>"
47
47
  - !ruby/object:Gem::Version
48
- version: '12.0'
48
+ version: '13.0'
49
49
  type: :development
50
50
  prerelease: false
51
51
  version_requirements: !ruby/object:Gem::Requirement
52
52
  requirements:
53
53
  - - "~>"
54
54
  - !ruby/object:Gem::Version
55
- version: '12.0'
55
+ version: '13.0'
56
56
  - !ruby/object:Gem::Dependency
57
57
  name: minitest
58
58
  requirement: !ruby/object:Gem::Requirement
@@ -81,20 +81,6 @@ dependencies:
81
81
  - - "~>"
82
82
  - !ruby/object:Gem::Version
83
83
  version: '1.1'
84
- - !ruby/object:Gem::Dependency
85
- name: appraisal
86
- requirement: !ruby/object:Gem::Requirement
87
- requirements:
88
- - - "~>"
89
- - !ruby/object:Gem::Version
90
- version: '2.0'
91
- type: :development
92
- prerelease: false
93
- version_requirements: !ruby/object:Gem::Requirement
94
- requirements:
95
- - - "~>"
96
- - !ruby/object:Gem::Version
97
- version: '2.0'
98
84
  description: ActiveRecord connection adapter for PostGIS. It is based on the stock
99
85
  PostgreSQL adapter, and adds built-in support for the spatial extensions provided
100
86
  by PostGIS. It uses the RGeo library to represent spatial data in Ruby.
@@ -110,12 +96,9 @@ files:
110
96
  - lib/active_record/connection_adapters/postgis/arel_tosql.rb
111
97
  - lib/active_record/connection_adapters/postgis/column_methods.rb
112
98
  - lib/active_record/connection_adapters/postgis/create_connection.rb
113
- - lib/active_record/connection_adapters/postgis/databases.rake
99
+ - lib/active_record/connection_adapters/postgis/database_statements.rb
114
100
  - lib/active_record/connection_adapters/postgis/oid/spatial.rb
115
- - lib/active_record/connection_adapters/postgis/postgis_database_tasks.rb
116
- - lib/active_record/connection_adapters/postgis/railtie.rb
117
101
  - lib/active_record/connection_adapters/postgis/schema_statements.rb
118
- - lib/active_record/connection_adapters/postgis/setup.rb
119
102
  - lib/active_record/connection_adapters/postgis/spatial_column.rb
120
103
  - lib/active_record/connection_adapters/postgis/spatial_column_info.rb
121
104
  - lib/active_record/connection_adapters/postgis/spatial_table_definition.rb
@@ -126,7 +109,8 @@ files:
126
109
  homepage: http://github.com/rgeo/activerecord-postgis-adapter
127
110
  licenses:
128
111
  - BSD-3-Clause
129
- metadata: {}
112
+ metadata:
113
+ rubygems_mfa_required: 'true'
130
114
  post_install_message:
131
115
  rdoc_options: []
132
116
  require_paths:
@@ -135,14 +119,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
135
119
  requirements:
136
120
  - - ">="
137
121
  - !ruby/object:Gem::Version
138
- version: 2.5.0
122
+ version: 2.7.0
139
123
  required_rubygems_version: !ruby/object:Gem::Requirement
140
124
  requirements:
141
125
  - - ">="
142
126
  - !ruby/object:Gem::Version
143
127
  version: '0'
144
128
  requirements: []
145
- rubygems_version: 3.0.8
129
+ rubygems_version: 3.1.4
146
130
  signing_key:
147
131
  specification_version: 4
148
132
  summary: ActiveRecord adapter for PostGIS, based on RGeo.
@@ -1,19 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- namespace :db do
4
- namespace :gis do
5
- desc 'Setup PostGIS data in the database'
6
- task setup: [:load_config] do
7
- environments = [Rails.env]
8
- environments << 'test' if Rails.env.development?
9
- environments.each do |environment|
10
- ActiveRecord::Base.configurations
11
- .configs_for(env_name: environment)
12
- .reject { |env| env.configuration_hash[:database].blank? }
13
- .each do |env|
14
- ActiveRecord::ConnectionAdapters::PostGIS::PostGISDatabaseTasks.new(env).setup_gis
15
- end
16
- end
17
- end
18
- end
19
- end
@@ -1,142 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module ActiveRecord # :nodoc:
4
- module ConnectionAdapters # :nodoc:
5
- module PostGIS # :nodoc:
6
- class PostGISDatabaseTasks < ::ActiveRecord::Tasks::PostgreSQLDatabaseTasks # :nodoc:
7
- def initialize(db_config)
8
- super
9
- ensure_installation_configs
10
- end
11
-
12
- def setup_gis
13
- establish_su_connection
14
- if extension_names
15
- setup_gis_from_extension
16
- end
17
- establish_connection(db_config)
18
- end
19
-
20
- # Override to set the database owner and call setup_gis
21
- def create(master_established = false)
22
- establish_master_connection unless master_established
23
- extra_configs = { encoding: encoding }
24
- extra_configs[:owner] = username if has_su?
25
- connection.create_database(db_config.database, configuration_hash.merge(extra_configs))
26
- setup_gis
27
- rescue ::ActiveRecord::StatementInvalid => error
28
- if /database .* already exists/ === error.message
29
- raise ::ActiveRecord::DatabaseAlreadyExists
30
- else
31
- raise
32
- end
33
- end
34
-
35
- private
36
-
37
- # Override to use su_username and su_password
38
- def establish_master_connection
39
- establish_connection(configuration_hash.merge(
40
- database: "postgres",
41
- password: su_password,
42
- schema_search_path: "public",
43
- username: su_username
44
- ))
45
- end
46
-
47
- def establish_su_connection
48
- establish_connection(configuration_hash.merge(
49
- password: su_password,
50
- schema_search_path: "public",
51
- username: su_username
52
- ))
53
- end
54
-
55
- def username
56
- @username ||= configuration_hash[:username]
57
- end
58
-
59
- def quoted_username
60
- @quoted_username ||= ::ActiveRecord::Base.connection.quote_column_name(username)
61
- end
62
-
63
- def password
64
- @password ||= configuration_hash[:password]
65
- end
66
-
67
- def su_username
68
- @su_username ||= configuration_hash.fetch(:su_username, username)
69
- end
70
-
71
- def su_password
72
- @su_password ||= configuration_hash.fetch(:su_password, password)
73
- end
74
-
75
- def has_su?
76
- return @has_su if defined?(@has_su)
77
-
78
- @has_su = configuration_hash.include?(:su_username)
79
- end
80
-
81
- def search_path
82
- @search_path ||= configuration_hash[:schema_search_path].to_s.strip.split(",").map(&:strip)
83
- end
84
-
85
- def extension_names
86
- @extension_names ||= begin
87
- extensions = configuration_hash[:postgis_extension]
88
- case extensions
89
- when ::String
90
- extensions.split(",")
91
- when ::Array
92
- extensions
93
- else
94
- ["postgis"]
95
- end
96
- end
97
- end
98
-
99
- def ensure_installation_configs
100
- if configuration_hash[:setup] == "default" && !configuration_hash[:postgis_extension]
101
- share_dir = `pg_config --sharedir`.strip rescue "/usr/share"
102
- control_file = ::File.expand_path("extension/postgis.control", share_dir)
103
- if ::File.readable?(control_file)
104
- @configuration_hash = configuration_hash.merge(postgis_extension: "postgis").freeze
105
- end
106
- end
107
- end
108
-
109
- def setup_gis_from_extension
110
- extension_names.each do |extname|
111
- if extname == "postgis_topology"
112
- unless search_path.include?("topology")
113
- raise ArgumentError, "'topology' must be in schema_search_path for postgis_topology"
114
- end
115
- connection.execute("CREATE EXTENSION IF NOT EXISTS #{extname} SCHEMA topology")
116
- else
117
- if (postgis_schema = configuration_hash[:postgis_schema])
118
- schema_clause = "WITH SCHEMA #{postgis_schema}"
119
- unless schema_exists?(postgis_schema)
120
- connection.execute("CREATE SCHEMA #{postgis_schema}")
121
- connection.execute("GRANT ALL ON SCHEMA #{postgis_schema} TO PUBLIC")
122
- end
123
- else
124
- schema_clause = ""
125
- end
126
-
127
- connection.execute("CREATE EXTENSION IF NOT EXISTS #{extname} #{schema_clause}")
128
- end
129
- end
130
- end
131
-
132
- def schema_exists?(schema_name)
133
- connection.execute(
134
- "SELECT schema_name FROM information_schema.schemata WHERE schema_name = '#{schema_name}'"
135
- ).any?
136
- end
137
- end
138
-
139
- ::ActiveRecord::Tasks::DatabaseTasks.register_task(/postgis/, PostGISDatabaseTasks)
140
- end
141
- end
142
- end
@@ -1,13 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module ActiveRecord # :nodoc:
4
- module ConnectionAdapters # :nodoc:
5
- module PostGIS # :nodoc:
6
- class Railtie < ::Rails::Railtie # :nodoc:
7
- rake_tasks do
8
- load "active_record/connection_adapters/postgis/databases.rake"
9
- end
10
- end
11
- end
12
- end
13
- end
@@ -1,19 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module ActiveRecord # :nodoc:
4
- module ConnectionAdapters # :nodoc:
5
- module PostGIS # :nodoc:
6
- def self.initial_setup
7
- ::ActiveRecord::SchemaDumper.ignore_tables |= %w(
8
- geography_columns
9
- geometry_columns
10
- layer
11
- raster_columns
12
- raster_overviews
13
- spatial_ref_sys
14
- topology
15
- )
16
- end
17
- end
18
- end
19
- end