defmodule Towerops.Repo.Migrations.CreateSnmpVlans do
  use Ecto.Migration

  def change do
    create table(:snmp_vlans, primary_key: false) do
      add :id, :binary_id, primary_key: true

      add :snmp_device_id, references(:snmp_devices, type: :binary_id, on_delete: :delete_all),
        null: false

      add :vlan_id, :integer, null: false
      add :vlan_name, :string
      add :vlan_type, :string
      add :status, :string, default: "active"
      add :last_checked_at, :utc_datetime
      add :metadata, :map, default: %{}

      timestamps(type: :utc_datetime)
    end

    create index(:snmp_vlans, [:snmp_device_id])
    create unique_index(:snmp_vlans, [:snmp_device_id, :vlan_id])
    create index(:snmp_vlans, [:status])
  end
end
