Skip to content

Commit

Permalink
Change the migration to also move instance_data and do not reset the …
Browse files Browse the repository at this point in the history
…system_information on rollback
  • Loading branch information
felixsch committed Oct 26, 2023
1 parent 3aedd9d commit cfd1bcc
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 22 deletions.
8 changes: 2 additions & 6 deletions db/migrate/20230814105634_move_hw_info_to_systems_table.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,8 @@ def up
'arch', nullif(hw.arch, ''), \
'uuid', nullif(hw.uuid, ''), \
'cloud_provider', nullif(hw.cloud_provider, ''));"
end
end

def down
safety_assured do
execute 'update systems set system_information = json_object();'
execute "update systems as s inner join hw_infos hw on s.id=hw.system_id \
set s.instance_data = hw.instance_data;"
end
end
end
31 changes: 15 additions & 16 deletions db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
#
# 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|
create_table "activations", charset: "utf8mb3", collation: "utf8mb3_general_ci", force: :cascade do |t|
t.bigint "service_id", null: false
t.bigint "system_id", null: false
t.datetime "created_at", null: false
Expand All @@ -24,14 +24,14 @@
t.index ["system_id"], name: "index_activations_on_system_id"
end

create_table "deregistered_systems", charset: "utf8", force: :cascade do |t|
create_table "deregistered_systems", charset: "utf8mb3", collation: "utf8mb3_general_ci", force: :cascade do |t|
t.bigint "scc_system_id", null: false, comment: "SCC IDs of deregistered systems; used for forwarding to SCC"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index ["scc_system_id"], name: "index_deregistered_systems_on_scc_system_id", unique: true
end

create_table "downloaded_files", charset: "utf8", force: :cascade do |t|
create_table "downloaded_files", charset: "utf8mb3", collation: "utf8mb3_general_ci", force: :cascade do |t|
t.string "checksum_type"
t.string "checksum"
t.string "local_path"
Expand All @@ -40,7 +40,7 @@
t.index ["local_path"], name: "index_downloaded_files_on_local_path", unique: true
end

create_table "hw_infos", charset: "utf8", force: :cascade do |t|
create_table "hw_infos", charset: "utf8mb3", collation: "utf8mb3_general_ci", force: :cascade do |t|
t.integer "cpus"
t.integer "sockets"
t.string "hypervisor"
Expand All @@ -51,12 +51,11 @@
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

create_table "product_predecessors", charset: "utf8", force: :cascade do |t|
create_table "product_predecessors", charset: "utf8mb3", collation: "utf8mb3_general_ci", force: :cascade do |t|
t.bigint "product_id", null: false
t.bigint "predecessor_id"
t.integer "kind", default: 0, null: false
Expand All @@ -65,7 +64,7 @@
t.index ["product_id"], name: "index_product_predecessors_on_product_id"
end

create_table "products", charset: "utf8", force: :cascade do |t|
create_table "products", charset: "utf8mb3", collation: "utf8mb3_general_ci", force: :cascade do |t|
t.string "name"
t.text "description"
t.string "shortname"
Expand All @@ -83,7 +82,7 @@
t.string "friendly_version"
end

create_table "products_extensions", charset: "utf8", force: :cascade do |t|
create_table "products_extensions", charset: "utf8mb3", collation: "utf8mb3_general_ci", force: :cascade do |t|
t.bigint "product_id", null: false
t.bigint "extension_id", null: false
t.boolean "recommended"
Expand All @@ -95,7 +94,7 @@
t.index ["root_product_id"], name: "fk_rails_7d0e68d364"
end

create_table "repositories", charset: "utf8", force: :cascade do |t|
create_table "repositories", charset: "utf8mb3", collation: "utf8mb3_general_ci", force: :cascade do |t|
t.bigint "scc_id", unsigned: true
t.string "name", null: false
t.string "description"
Expand All @@ -113,29 +112,29 @@
t.index ["scc_id"], name: "index_repositories_on_scc_id", unique: true
end

create_table "repositories_services", charset: "utf8", force: :cascade do |t|
create_table "repositories_services", charset: "utf8mb3", collation: "utf8mb3_general_ci", force: :cascade do |t|
t.bigint "repository_id", null: false
t.bigint "service_id", null: false
t.index ["repository_id"], name: "index_repositories_services_on_repository_id"
t.index ["service_id", "repository_id"], name: "index_repositories_services_on_service_id_and_repository_id", unique: true
t.index ["service_id"], name: "index_repositories_services_on_service_id"
end

create_table "services", charset: "utf8", force: :cascade do |t|
create_table "services", charset: "utf8mb3", collation: "utf8mb3_general_ci", force: :cascade do |t|
t.bigint "product_id", null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index ["product_id"], name: "index_services_on_product_id", unique: true
end

create_table "subscription_product_classes", charset: "utf8", force: :cascade do |t|
create_table "subscription_product_classes", charset: "utf8mb3", collation: "utf8mb3_general_ci", force: :cascade do |t|
t.bigint "subscription_id", null: false
t.string "product_class", null: false
t.index ["subscription_id", "product_class"], name: "index_product_class_unique", unique: true
t.index ["subscription_id"], name: "index_subscription_product_classes_on_subscription_id"
end

create_table "subscriptions", charset: "utf8", force: :cascade do |t|
create_table "subscriptions", charset: "utf8mb3", collation: "utf8mb3_general_ci", force: :cascade do |t|
t.string "regcode", null: false
t.string "name", null: false
t.string "kind", null: false
Expand All @@ -150,7 +149,7 @@
t.index ["regcode"], name: "index_subscriptions_on_regcode"
end

create_table "systems", charset: "utf8", force: :cascade do |t|
create_table "systems", charset: "utf8mb3", collation: "utf8mb3_general_ci", force: :cascade do |t|
t.string "login"
t.string "password"
t.string "hostname"
Expand All @@ -162,7 +161,7 @@
t.bigint "scc_system_id", comment: "System ID in SCC (if the system registration was forwarded; needed for forwarding de-registrations)"
t.boolean "proxy_byos", default: false
t.string "system_token"
t.text "system_information", size: :long
t.text "system_information", size: :long, collation: "utf8mb4_bin"
t.string "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"
Expand Down

0 comments on commit cfd1bcc

Please sign in to comment.