We need this when removing a boot image, when we want to update available storage on the storage device. Alternatively, we could get the size using an ssh command when removing the boot image. But since this is also useful as a way of double-checking approximate total used size on a storage device, where we can just sum vm_storage_volume and boot_image sizes on it.
30 lines
826 B
Ruby
30 lines
826 B
Ruby
# frozen_string_literal: true
|
|
|
|
Sequel.migration do
|
|
change do
|
|
alter_table(:boot_image) do
|
|
add_column :size_gib, Integer, null: true
|
|
end
|
|
|
|
# Update existing boot images
|
|
run <<-SQL
|
|
UPDATE boot_image
|
|
SET size_gib = CASE
|
|
WHEN boot_image.name = 'ubuntu-jammy' THEN 3
|
|
WHEN boot_image.name = 'almalinux-9.1' THEN 10
|
|
WHEN vm_host.arch = 'x64' AND boot_image.name LIKE 'github-ubuntu-%' THEN 75
|
|
WHEN vm_host.arch = 'arm64' AND boot_image.name LIKE 'github-ubuntu-%' THEN 50
|
|
WHEN boot_image.name = 'github-gpu-ubuntu-2204' THEN 31
|
|
WHEN boot_image.name LIKE 'postgres-%' THEN 8
|
|
ELSE 0
|
|
END
|
|
FROM vm_host
|
|
WHERE boot_image.vm_host_id = vm_host.id;
|
|
SQL
|
|
|
|
alter_table(:boot_image) do
|
|
set_column_not_null :size_gib
|
|
end
|
|
end
|
|
end
|