-
Notifications
You must be signed in to change notification settings - Fork 168
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #77 from rails-on-services/development
Prepare Release - 2.7.0 # Enhancements - [Resolves #70] Rake tasks define methods on main - #75 - Add database and schema to active record log. Configurable, defaults to false to keep current behavior - #55 # Bugfixes - [Fixes #61] Fix database create in mysql - #76 # Chores - Remove depracated tld_length config option: tld_length was removed in influitive#309, this configuration option doesn't have any effect now. - #72 - Using [diffend.io proxy](https://diffend.io) to safely check required gems - Added [story branch](https://github.com/story-branch/story_branch) to the configuration - Using travis-ci to run rubocop as well, replacing github actions: github actions do not work in fork's PRs
- Loading branch information
Showing
22 changed files
with
198 additions
and
98 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains 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 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 |
---|---|---|
@@ -1,4 +1,5 @@ | ||
--- | ||
tracker: github | ||
issue_placement: beginning | ||
project_id: | ||
- rails-on-services/apartment |
This file contains 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 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 |
---|---|---|
@@ -1,6 +1,6 @@ | ||
# frozen_string_literal: true | ||
|
||
source 'http://rubygems.org' | ||
source 'https://my.diffend.io/protect/gems' | ||
|
||
gemspec | ||
|
||
|
This file contains 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 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 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 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 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,41 @@ | ||
# frozen_string_literal: true | ||
|
||
module ActiveRecord | ||
class LogSubscriber | ||
def apartment_log | ||
return unless Apartment.active_record_log | ||
|
||
database = color("[#{Apartment.connection.current_database}] ", ActiveSupport::LogSubscriber::MAGENTA, true) | ||
schema = nil | ||
schema = color("[#{Apartment.connection.schema_search_path.tr('"', '')}] ", ActiveSupport::LogSubscriber::YELLOW, true) unless Apartment.connection.schema_search_path.nil? | ||
"#{database}#{schema}" | ||
end | ||
|
||
def payload_binds(binds, type_casted_binds) | ||
return unless (binds || []).empty? | ||
|
||
casted_params = type_casted_binds(type_casted_binds) | ||
binds = ' ' + binds.zip(casted_params).map { |attr, value| render_bind(attr, value) }.inspect | ||
binds | ||
end | ||
|
||
def sql(event) | ||
self.class.runtime += event.duration | ||
return unless logger.debug? | ||
|
||
payload = event.payload | ||
|
||
return if IGNORE_PAYLOAD_NAMES.include?(payload[:name]) | ||
|
||
name = "#{payload[:name]} (#{event.duration.round(1)}ms)" | ||
name = "CACHE #{name}" if payload[:cached] | ||
sql = payload[:sql] | ||
binds = payload_binds(payload[:binds], payload[:type_casted_binds]) | ||
|
||
name = colorize_payload_name(name, payload[:name]) | ||
sql = color(sql, sql_color(sql), true) if colorize_logging | ||
|
||
debug " #{apartment_log}#{name} #{sql}#{binds}" | ||
end | ||
end | ||
end |
This file contains 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 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 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 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 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,35 @@ | ||
# frozen_string_literal: true | ||
|
||
module Apartment | ||
module TaskHelper | ||
def self.each_tenant(&block) | ||
Parallel.each(tenants_without_default, in_threads: Apartment.parallel_migration_threads) do |tenant| | ||
block.call(tenant) | ||
end | ||
end | ||
|
||
def self.tenants_without_default | ||
tenants - [Apartment.default_tenant] | ||
end | ||
|
||
def self.tenants | ||
ENV['DB'] ? ENV['DB'].split(',').map(&:strip) : Apartment.tenant_names || [] | ||
end | ||
|
||
def self.warn_if_tenants_empty | ||
return unless tenants.empty? && ENV['IGNORE_EMPTY_TENANTS'] != 'true' | ||
|
||
# rubocop:disable Rails/Output | ||
puts <<-WARNING | ||
[WARNING] - The list of tenants to migrate appears to be empty. This could mean a few things: | ||
1. You may not have created any, in which case you can ignore this message | ||
2. You've run `apartment:migrate` directly without loading the Rails environment | ||
* `apartment:migrate` is now deprecated. Tenants will automatically be migrated with `db:migrate` | ||
Note that your tenants currently haven't been migrated. You'll need to run `db:migrate` to rectify this. | ||
WARNING | ||
# rubocop:enable Rails/Output | ||
end | ||
end | ||
end |
This file contains 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 |
---|---|---|
@@ -1,5 +1,5 @@ | ||
# frozen_string_literal: true | ||
|
||
module Apartment | ||
VERSION = '2.6.1' | ||
VERSION = '2.7.0' | ||
end |
This file contains 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
Oops, something went wrong.