diff --git a/db/migrate/20230814105634_move_hw_info_to_systems_table.rb b/db/migrate/20230814105634_move_hw_info_to_systems_table.rb index 234002dc0..3be0b9772 100644 --- a/db/migrate/20230814105634_move_hw_info_to_systems_table.rb +++ b/db/migrate/20230814105634_move_hw_info_to_systems_table.rb @@ -1,20 +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, ''));" + 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 - safety_assured do - execute 'update systems set system_information = json_object();' - end + change_column :systems, :instance_data, :string end end diff --git a/db/schema.rb b/db/schema.rb index 64be49b09..1f3795dbe 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 2022_07_11_152732) do +ActiveRecord::Schema.define(version: 2023_08_14_105634) do create_table "activations", charset: "utf8", force: :cascade do |t| t.bigint "service_id", null: false @@ -51,7 +51,6 @@ t.datetime "updated_at", null: false t.text "instance_data", comment: "Additional client information, e.g. instance identity document" t.string "cloud_provider" - t.boolean "proxy_byos", default: false t.index ["hypervisor"], name: "index_hw_infos_on_hypervisor" t.index ["system_id"], name: "index_hw_infos_on_system_id", unique: true end @@ -163,7 +162,7 @@ t.boolean "proxy_byos", default: false t.string "system_token" t.text "system_information", size: :long - t.string "instance_data" + t.text "instance_data" t.index ["login", "password", "system_token"], name: "index_systems_on_login_and_password_and_system_token", unique: true t.index ["login", "password"], name: "index_systems_on_login_and_password" t.check_constraint "json_valid(`system_information`)", name: "system_information" diff --git a/engines/registration_sharing/app/controllers/registration_sharing/rmt_to_rmt_controller.rb b/engines/registration_sharing/app/controllers/registration_sharing/rmt_to_rmt_controller.rb index 52594f9f4..7d06ddef6 100644 --- a/engines/registration_sharing/app/controllers/registration_sharing/rmt_to_rmt_controller.rb +++ b/engines/registration_sharing/app/controllers/registration_sharing/rmt_to_rmt_controller.rb @@ -34,7 +34,7 @@ def destroy protected def system_params - params.permit(:login, :password, :hostname, :proxy_byos, :system_token, :registered_at, :created_at, :last_seen_at) + params.permit(:login, :password, :hostname, :proxy_byos, :system_token, :registered_at, :created_at, :last_seen_at, :instance_data) end def authenticate diff --git a/package/obs/rmt-server.spec b/package/obs/rmt-server.spec index 61ba0b7d4..aeba35522 100644 --- a/package/obs/rmt-server.spec +++ b/package/obs/rmt-server.spec @@ -342,6 +342,11 @@ if [ $1 -eq 2 ]; then mv %{app_dir}/config/system_uuid /var/lib/rmt/system_uuid fi bash %{script_dir}/update_rmt_app_dir_permissions.sh %{app_dir} + + echo "RMT database migration in progress. This could take some time." + echo "" + echo "To check current migration status:" + echo " systemctl status rmt-server-migration.service" fi if [ ! -e %{_datadir}/rmt/public/repo ]; then