Skip to content

Commit

Permalink
Add support for different assessment based on machine type
Browse files Browse the repository at this point in the history
  • Loading branch information
zacksiri committed Jun 28, 2024
1 parent 9d7d736 commit 3b02639
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
5 changes: 5 additions & 0 deletions lib/polar/machines/assessment.ex
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,20 @@ defmodule Polar.Machines.Assessment do
@valid_attrs ~w(
check_id
cluster_id
machine_type
)a

@required_attrs ~w(
check_id
cluster_id
machine_type
)a

schema "assessments" do
field :current_state, :string, default: "created"

field :machine_type, :string

belongs_to :check, Check
belongs_to :cluster, Cluster

Expand All @@ -40,5 +44,6 @@ defmodule Polar.Machines.Assessment do
assessment
|> cast(attrs, @valid_attrs)
|> validate_required(@required_attrs)
|> validate_inclusion(:machine_type, ["container", "vm"])
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
defmodule Polar.Repo.Migrations.AddMachineTypeToAssessments do
use Ecto.Migration

def change do
alter table(:assessments) do
add :machine_type, :string, null: false
end

drop index(:assessments, [:check_id, :version_id], unique: true)
create index(:assessments, [:check_id, :version_id, :machine_type], unique: true)
end
end

0 comments on commit 3b02639

Please sign in to comment.