forked from mikecmpbll/apartment
-
Notifications
You must be signed in to change notification settings - Fork 1
Flexible switching with rails 5.2 #1
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
Closed
Closed
Changes from all commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
8010531
Removed task dependency
meganemura 676fb98
Kernel#quietly was deprecated in Rails 4.2
brownbeagle c6a221c
enhance db:drop task
kuzukuzu 8d89b82
Support ActiveRecord-5.2 migration context
IngusSkaistkalns e28e870
Call drop database for postgres
derosm2 63c8b06
No longer set default tenant to a hash
derosm2 f13b203
Use guard clause
meganemura 29af321
Swallow the AR::NoDatabaseError
meganemura 92359d8
Fix calls to connection_switch! method
derosm2 18cdf10
Always use postgresql adapter
derosm2 698b688
Rescue from expected errors when dropping a database
derosm2 825444a
Rescue expected errors when creating tenant
derosm2 e3ca496
Account for different ports and fallback to postgres db
derosm2 047061d
Actually switch the connection
derosm2 8838a9d
Fix seed rake task
derosm2 12fbee2
Clear connections after rake tasks
derosm2 f2bf69f
Add public method for cleaning connections
derosm2 ca45dc0
Always switch to thread specific connection when possible
derosm2 1e9ca1f
Remove default_db var
derosm2 b603d63
Add database config resolver
derosm2 26ace7c
Remove extra call to establish connection
derosm2 795648a
Call init again to ensure setup_connection_specification_name is called
derosm2 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| require 'apartment/resolvers/abstract' | ||
|
|
||
| module Apartment | ||
| module Resolvers | ||
| class Config < Abstract | ||
| def resolve(tenant) | ||
| return init_config.dup if !tenant || tenant == Apartment.default_tenant | ||
|
|
||
| database_config(tenant) | ||
| end | ||
|
|
||
| private | ||
|
|
||
| def database_config(tenant) | ||
| ActiveRecord::Base.configurations[config_name(tenant)].symbolize_keys | ||
| end | ||
|
|
||
| def config_name(tenant) | ||
| "#{Rails.env}_#{tenant}" | ||
| end | ||
| end | ||
| end | ||
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.