towerops/priv/repo/migrations/20260213144412_create_preseem_insights.exs

32 lines
1.1 KiB
Elixir

defmodule Towerops.Repo.Migrations.CreatePreseemInsights do
use Ecto.Migration
def change do
create table(:preseem_insights, primary_key: false) do
add :id, :binary_id, primary_key: true
add :organization_id, references(:organizations, type: :binary_id, on_delete: :delete_all),
null: false
add :preseem_access_point_id,
references(:preseem_access_points, type: :binary_id, on_delete: :delete_all)
add :device_id, references(:devices, type: :binary_id, on_delete: :nilify_all)
add :type, :string, null: false
add :urgency, :string, null: false
add :status, :string, null: false, default: "active"
add :channel, :string, null: false
add :title, :string, null: false
add :description, :text
add :metadata, :map
add :dismissed_at, :utc_datetime
timestamps(type: :utc_datetime)
end
create index(:preseem_insights, [:organization_id])
create index(:preseem_insights, [:preseem_access_point_id])
create index(:preseem_insights, [:device_id])
create index(:preseem_insights, [:organization_id, :status])
end
end