-
Notifications
You must be signed in to change notification settings - Fork 19
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 #2498 from internetee/fix-statistics
Refactored market share distribution request
- Loading branch information
Showing
9 changed files
with
379 additions
and
63 deletions.
There are no files selected for viewing
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,26 @@ | ||
# Mark existing migrations as safe | ||
StrongMigrations.start_after = 20221206081743 | ||
|
||
# Set timeouts for migrations | ||
# If you use PgBouncer in transaction mode, delete these lines and set timeouts on the database user | ||
StrongMigrations.lock_timeout = 10.seconds | ||
StrongMigrations.statement_timeout = 1.hour | ||
|
||
# Analyze tables after indexes are added | ||
# Outdated statistics can sometimes hurt performance | ||
StrongMigrations.auto_analyze = true | ||
|
||
# Set the version of the production database | ||
# so the right checks are run in development | ||
# StrongMigrations.target_version = 10 | ||
|
||
# Add custom checks | ||
# StrongMigrations.add_check do |method, args| | ||
# if method == :add_index && args[0].to_s == "users" | ||
# stop! "No more indexes on the users table" | ||
# end | ||
# end | ||
|
||
# Make some operations safe by default | ||
# See https://github.com/ankane/strong_migrations#safe-by-default | ||
# StrongMigrations.safe_by_default = true |
21 changes: 21 additions & 0 deletions
21
db/migrate/20221206090120_modify_log_domains_object_changes_data_type.rb
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,21 @@ | ||
class ModifyLogDomainsObjectChangesDataType < ActiveRecord::Migration[6.1] | ||
def up | ||
add_column :log_domains, :object_changes_jsonb, :jsonb, default: '{}' | ||
|
||
# Copy data from old column to the new one | ||
Version::DomainVersion.update_all('object_changes_jsonb = object_changes::jsonb') | ||
|
||
# Rename columns instead of modify their type, it's way faster | ||
safety_assured do | ||
rename_column :log_domains, :object_changes, :object_changes_json | ||
rename_column :log_domains, :object_changes_jsonb, :object_changes | ||
end | ||
end | ||
|
||
def down | ||
safety_assured do | ||
rename_column :log_domains, :object_changes, :object_changes_jsonb | ||
rename_column :log_domains, :object_changes_json, :object_changes | ||
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 |
---|---|---|
@@ -0,0 +1,15 @@ | ||
class AddIndexesToLogDomains < ActiveRecord::Migration[6.1] | ||
disable_ddl_transaction! | ||
def up | ||
enable_extension 'btree_gin' | ||
add_index :log_domains, :event, algorithm: :concurrently | ||
add_index :log_domains, :object, using: :gin, algorithm: :concurrently | ||
add_index :log_domains, :object_changes, using: :gin, algorithm: :concurrently | ||
end | ||
|
||
def down | ||
remove_index :log_domains, :event | ||
remove_index :log_domains, :object | ||
remove_index :log_domains, :object_changes | ||
end | ||
end |
5 changes: 5 additions & 0 deletions
5
db/migrate/20221207102831_change_log_domains_object_changes_default_value.rb
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,5 @@ | ||
class ChangeLogDomainsObjectChangesDefaultValue < ActiveRecord::Migration[6.1] | ||
def change | ||
change_column_default :log_domains, :object_changes, nil | ||
end | ||
end |
Oops, something went wrong.