-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make systems.instance_data a text rather then a string and cleanup sc…
…hema.rb
- Loading branch information
Showing
2 changed files
with
30 additions
and
25 deletions.
There are no files selected for viewing
25 changes: 15 additions & 10 deletions
25
db/migrate/20230814105634_move_hw_info_to_systems_table.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 |
---|---|---|
@@ -1,16 +1,21 @@ | ||
class MoveHwInfoToSystemsTable < ActiveRecord::Migration[6.1] | ||
def up | ||
safety_assured do | ||
execute "update systems as s inner join hw_infos hw on s.id=hw.system_id \ | ||
set system_information = json_object(\ | ||
'cpus', hw.cpus, \ | ||
'sockets', hw.sockets, \ | ||
'hypervisor', nullif(hw.hypervisor, ''), \ | ||
'arch', nullif(hw.arch, ''), \ | ||
'uuid', nullif(hw.uuid, ''), \ | ||
'cloud_provider', nullif(hw.cloud_provider, ''));" | ||
execute "update systems as s inner join hw_infos hw on s.id=hw.system_id \ | ||
set s.instance_data = hw.instance_data;" | ||
change_column :systems, :instance_data, :text | ||
|
||
execute "UPDATE systems AS s INNER JOIN hw_infos hw ON s.id=hw.system_id \ | ||
SET s.system_information = json_object( \ | ||
'cpus', hw.cpus, \ | ||
'sockets', hw.sockets, \ | ||
'hypervisor', nullif(hw.hypervisor, ''), \ | ||
'arch', nullif(hw.arch, ''), \ | ||
'uuid', nullif(hw.uuid, ''), \ | ||
'cloud_provider', nullif(hw.cloud_provider, '')), \ | ||
s.instance_data = hw.instance_data;" | ||
end | ||
end | ||
|
||
def down | ||
change_column :systems, :instance_data, :string | ||
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