ubicloud/migrate/20251003_vm_init_script.rb
Jeremy Evans da54dbba9f Add migration for vm_init_script table
This adds a foreign key in the vm table for the init script, and
a string column for the args to the init script. This allows easy
separation of per-VM data from multiple VM data

Unlike SSH public keys, We will not track per-VM init scripts, all
VM init scripts will need to be registered with the project to be
used (we can support auto registration on VM creation if we want).
2025-10-04 11:53:04 -07:00

19 lines
557 B
Ruby

# frozen_string_literal: true
Sequel.migration do
change do
create_table(:vm_init_script) do
# UBID.to_base32_n("1n") => 53
column :id, :uuid, primary_key: true, default: Sequel.lit("gen_random_ubid_uuid(53)")
foreign_key :project_id, :project, type: :uuid, null: false
String :name, null: false
String :script, null: false
unique [:project_id, :name]
end
alter_table(:vm) do
add_foreign_key :init_script_id, :vm_init_script, type: :uuid
add_column :init_script_args, String
end
end
end