Updated database connection handling via pg_dump.#128
Updated database connection handling via pg_dump.#128vdragsic wants to merge 6 commits intoinfluitive:developmentfrom
Conversation
|
+1 |
|
From what I can see here, the problem with the excluded models is not really being fixed by leaving out those models when dumping/restoring. Now your FK constraints won't be prepended by the schema unless they point to a table in a different schema, than the one you dump from. Let me give an example: Let's say you have an excluded model called --
-- PostgreSQL database dump
--
--
-- Name: food_blog; Type: SCHEMA; Schema: -; Owner: -
--
CREATE SCHEMA food_blog;
--
-- Name: SCHEMA food_blog; Type: COMMENT; Schema: -; Owner: -
--
COMMENT ON SCHEMA IS 'standard public schema';
SET search_path = food_blog;
(...)
--
-- Name: posts_user_id_fk; Type: FK CONSTRAINT; Schema: food_blog; Owner: -
--
ALTER TABLE ONLY posts
ADD CONSTRAINT posts_user_id_fk FOREIGN KEY (users_id) REFERENCES users(id);
Now we have a problem, because when creating the new schema ALTER TABLE ONLY posts
ADD CONSTRAINT posts_user_id_fk FOREIGN KEY (users_id) REFERENCES wine_blog.users(id);However that is never going to happen, because the wine_blog is your Now to get the right behavior, you would have to move all excluded models into a different schema (e.g. To wrap up, the best idea is probably to leave the excluded models in all schemas, then make sure, that your FK's referring to excluded models, refer to the excluded model tables residing in the Do you follow me? |
|
as a workaround for those waiting on this PR, pg_dump and friends support a variety of environment variables (e.g. PGUSER, PGPORT, etc.). when coupled with something like dotenv you can still keep all your db config in one place (e.g. database.yml could also pull from env vars) |
There was a problem hiding this comment.
I made an alternative to this: #182
…into development Conflicts: apartment.gemspec lib/apartment/adapters/postgresql_adapter.rb
Prepare Release - 2.8.1 **Implemented enhancements:** **Fixed bugs:** - New version raises an error with ActiveSupport::LogSubscriber [influitive#128](rails-on-services/apartment#128) - Weird logs when tenant fails to create [influitive#127](<rails-on-services/apartment#127>) **Closed issues:** - Removed travis and slim configured circleci [influitive#130](rails-on-services/apartment#130)
Connection arguments for
pg_dumpcommand are built from Rails.configuration.database_configuration` for current environment.This reflects only on
PostgresqlSchemaFromSqlAdapter.