I have a rails app that uses postgresql + some extensions, but every time I run rails db:migrate
it removes the lines that enable the extensions. I have to copy and paste it manually every time.
Lines being removed on db/structure.sql:
-- Name: EXTENSION "postgis"; Type: COMMENT; Schema: -; Owner: -
--
CREATE EXTENSION IF NOT EXISTS "postgis" WITH SCHEMA public;
--
-- Name: plpgsql; Type: EXTENSION; Schema: -; Owner: -
--
CREATE EXTENSION IF NOT EXISTS plpgsql WITH SCHEMA pg_catalog;
--
-- Name: EXTENSION plpgsql; Type: COMMENT; Schema: -; Owner: -
--
COMMENT ON EXTENSION plpgsql IS 'PL/pgSQL procedural language';
--
-- Name: pg_trgm; Type: EXTENSION; Schema: -; Owner: -
--
CREATE EXTENSION IF NOT EXISTS pg_trgm WITH SCHEMA public;
--
-- Name: EXTENSION pg_trgm; Type: COMMENT; Schema: -; Owner: -
--
COMMENT ON EXTENSION pg_trgm IS 'text similarity measurement and index searching based on trigrams';
--
-- Name: uuid-ossp; Type: EXTENSION; Schema: -; Owner: -
--
CREATE EXTENSION IF NOT EXISTS "uuid-ossp" WITH SCHEMA public;
--
-- Name: EXTENSION "uuid-ossp"; Type: COMMENT; Schema: -; Owner: -
--
COMMENT ON EXTENSION "uuid-ossp" IS 'generate universally unique identifiers (UUIDs)';
My database.yml:
default: &default
adapter: postgis
encoding: unicode
host: <%= ENV.fetch('DB_HOST', 'localhost') %>
username: <%= ENV.fetch('DB_USERNAME') %>
password: <%= ENV.fetch('DB_PASSWORD') %>
schema_search_path: public
test:
<<: *default
database: db_test
development:
<<: *default
database: db_development
production:
<<: *default
database: db_production
Any ideas how can I fix it?
I'm using the following versions:
postgresql: 9.6
postgis: 2.3
rails: 5.0
macOS: 10.12
UPDATE:
I managed to find a workaround to the problem. As I'm using schema_search_path
as public, if not defined the default option is public. Just removed this line from database.yml and it works now. Still no clues why it's happening when defining the schema_search_path
explicitly.