influitive / apartment

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

Fix tenant name substitution in pg dump #549

Closed ancorcruz closed 6 years ago

ancorcruz commented 6 years ago

Fixes Postgres schema creation with sql dump in edge cases when some elements like tables, indices or columns contains the default schema name. For example, a table called "public_tokens" with a foreign key when the default schema is also named "public".

The following is the error without the patch:

  ActiveRecord::StatementInvalid:
       PG::SyntaxError: ERROR:  syntax error at or near "_tokens"
       LINE 136: CREATE TABLE "db37"."db37"_tokens (

Related to: https://github.com/influitive/apartment/pull/537

ancorcruz commented 6 years ago

I'm using this branch in production without issues.

Any chance to get it merged soon?

mikecmpbll commented 6 years ago

ya this is a bug in original implementation. fix looks good. thank you so much :).