Reputation: 2834
Everytime I run rake db:migrate
on my project the db/structure.sql
changes and I'm happy. Unfortunately the changes are not only additions to my table but also something strage in explicitly using our tenant
keyword and extensions
keyword.
db/structure.sql | 20278 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++---------------------------------------------------------------------------------------------------------------
1 file changed, 9565 insertions(+), 10713 deletions(-)
This is part of my interesting diff after I migrate:
-CREATE FUNCTION _final_median_function(anyarray) RETURNS double precision
+CREATE FUNCTION extensions._final_median_function(anyarray) RETURNS double precision
and here is an example for table:
-SET search_path = at, pg_catalog;
-CREATE TABLE advert_all_clicks (
+CREATE TABLE at.advert_all_clicks (
Postgres 9.6.10 (also tested and it happens in 10.+) Multitenancy is done using apartment
Does anyone has any idea why this is happening? Could't find too much and I'm battling with this for a while.
Edit: In connection to my problem I found this but it applies to postgres < 9.3
Upvotes: 4
Views: 524
Reputation: 2834
This is strange but I'm going to respond just in case someone else has the same issue.
If you're on a project that uses db/xx.sql
file then if you open it, on very first lines you'll see the versions of pg_dump
and postgres
which were used to generate this dump.
In order to successfully restore from a dump or have this file db/xx.sql
clean while running db:migrate
you must have the same exact version installed. It's not working with a different major/minor/release (must be the exact same)
In my case first lines are looking like:
--
-- PostgreSQL database dump
--
-- Dumped from database version 9.6.5
-- Dumped by pg_dump version 9.6.5
I tried installing 9.6.10 (which is current [email protected]) and other different versions. It continue to mess with my file until I compiled exactly 9.6.5 from source.
Couldn't find an explanation for this and I don't see changes in the 9.6.x changelogs.
Soon I'll create a homebrew-tap and have it here as an example.
Upvotes: 1