-
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.
Created migration files for log_domains table json columns
- Loading branch information
Sergei Tsoganov
authored and
Sergei Tsoganov
committed
Jan 3, 2023
1 parent
e2c6c9e
commit b4429a5
Showing
3 changed files
with
47 additions
and
9 deletions.
There are no files selected for viewing
18 changes: 18 additions & 0 deletions
18
db/migrate/20230103095457_reverse_log_domains_object_changes_json.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,18 @@ | ||
class ReverseLogDomainsObjectChangesJson < ActiveRecord::Migration[6.1] | ||
def up | ||
safety_assured do | ||
remove_column :log_domains, :object_changes_json if column_exists? :log_domains, :object_changes_json | ||
add_column :log_domains, :object_changes_json, :json | ||
Version::DomainVersion.update_all('object_changes_json = object_changes::json') | ||
rename_column :log_domains, :object_changes, :object_changes_jsonb | ||
rename_column :log_domains, :object_changes_json, :object_changes | ||
end | ||
end | ||
|
||
def down | ||
safety_assured do | ||
rename_column :log_domains, :object_changes, :object_changes_json | ||
rename_column :log_domains, :object_changes_jsonb, :object_changes | ||
end | ||
end | ||
end |
18 changes: 18 additions & 0 deletions
18
db/migrate/20230103100621_reverse_log_domains_object_json.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,18 @@ | ||
class ReverseLogDomainsObjectJson < ActiveRecord::Migration[6.1] | ||
def up | ||
safety_assured do | ||
remove_column :log_domains, :object_json if column_exists? :log_domains, :object_json | ||
add_column :log_domains, :object_json, :json | ||
Version::DomainVersion.update_all('object_json = object::json') | ||
rename_column :log_domains, :object, :object_jsonb | ||
rename_column :log_domains, :object_json, :object | ||
end | ||
end | ||
|
||
def down | ||
safety_assured do | ||
rename_column :log_domains, :object, :object_json | ||
rename_column :log_domains, :object_jsonb, :object | ||
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