influitive / apartment

Database multi-tenancy for Rack (and Rails) applications
2.66k stars 464 forks source link

Ignore `CREATE SCHEMA public` statement in pg dump #586

Closed artemave closed 5 years ago

artemave commented 5 years ago

Fixes https://github.com/influitive/apartment/issues/581

tfwright commented 5 years ago

As far as I can tell this is blocking using apartment on Heroku, since their environment seems to always use pg_dump from version 11. Would be really nice to see this merged, if anyone is still maintaining this.

mjfrey commented 5 years ago

I am also blocked in Heroku -- is someone going to merge this?

danielolivaresd commented 5 years ago

Thanks for this. As a future reference (and for other ones having issues), this PR allows me to use schemas instead of separate DB connections and use UUID primary keys (e.g. using the following schema) with Postgres 11. Previously we had to opt for separate databases but we think that there are some threading issues with that approach. Anyway, it works now with the following setup:

# schema.rb
create_table "foos", id: :uuid, default: -> { "gen_random_uuid()" }, #...

My Apartment config looks like this:

# apartment.rb
Apartment.configure do |config|
  config.use_schemas = true
  config.use_sql = true
  config.pg_excluded_names = ["uuid_generate_v4", "gen_random_uuid"]
end

Are there any plans to release a new version of the gem that includes this and other recent PRs soon?

mikecmpbll commented 5 years ago

@K1N5L4Y3R yep i'll cut the release in the next couple of days just want to work through the rest of the backlog first see if there's any other low hanging fruit

danielolivaresd commented 5 years ago

Hey @mikecmpbll , thanks for your answer. This is a kind reminder about the release. Anything I or the community can do to help to expedite it?

mikecmpbll commented 5 years ago

whoops done as 2.2.1 :)