Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mysql2 Adapter doesn't escape tenant during drop #131

Closed
ghempton opened this issue Apr 16, 2014 · 0 comments · Fixed by #353
Closed

Mysql2 Adapter doesn't escape tenant during drop #131

ghempton opened this issue Apr 16, 2014 · 0 comments · Fixed by #353

Comments

@ghempton
Copy link

In a crunch and don't have time for a formal PR/tests, but for anyone else's reference, we fixed this with the following monkey patch:

require 'apartment/adapters/mysql2_adapter'

class Apartment::Adapters::Mysql2Adapter

  #   Drop the tenant
  #
  #   @param {String} tenant Database name
  #
  def drop(tenant)
    # Apartment.connection.drop_database   note that drop_database will not throw an exception, so manually execute
    Apartment.connection.execute("DROP DATABASE `#{environmentify(tenant)}`" )

  rescue *rescuable_exceptions
    raise DatabaseNotFound, "The tenant #{environmentify(tenant)} cannot be found"
  end

end
marksiemers pushed a commit to AbleHealth/apartment that referenced this issue Apr 13, 2021
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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant