Files
ubicloud/migrate/20250611_vhost_block_backend.rb
Hadi Moshayedi 0bcce84122 Migrations for VhostBlockBackend.
Adds the table & foreign keys for Ubiblk installation.
2025-06-11 11:24:17 -07:00

20 lines
705 B
Ruby

# frozen_string_literal: true
Sequel.migration do
change do
create_table(:vhost_block_backend) do
column :id, :uuid, primary_key: true, default: Sequel.function(:gen_random_ubid_uuid, 474) # "et" ubid type
column :created_at, :timestamptz, null: false, default: Sequel::CURRENT_TIMESTAMP
column :version, :text, null: false
column :allocation_weight, :integer, null: false
foreign_key :vm_host_id, :vm_host, type: :uuid, null: false
unique [:vm_host_id, :version]
check { allocation_weight >= 0 }
end
alter_table(:vm_storage_volume) do
add_foreign_key :vhost_block_backend_id, :vhost_block_backend, type: :uuid, null: true
end
end
end