fix(postgis): do not try to create postgis extension if it is already created or it is disabled

This commit is contained in:
Paul Chavard 2023-07-18 11:42:57 +02:00
parent 1e8a98329e
commit 735c504c0f
2 changed files with 6 additions and 1 deletions

View file

@ -207,3 +207,6 @@ COJO_JWT_RSA_PRIVATE_KEY=""
COJO_JWT_ISS=""
API_COJO_URL=""
# Set to `disabled` if you want to diable postgis
POSTGIS_EXTENSION_DISABLED=""

View file

@ -1,5 +1,7 @@
class EnablePostgis < ActiveRecord::Migration[7.0]
def change
enable_extension :postgis
if ENV['POSTGIS_EXTENSION_DISABLED'] != 'disabled' && ActiveRecord::Base.connection.execute("SELECT 1 as one FROM pg_extension WHERE extname = 'postgis';").count.zero?
enable_extension :postgis
end
end
end