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

  def change do
    create table(:ip_whitelist, primary_key: false) do
      add :id, :binary_id, primary_key: true
      add :ip_or_cidr, :string, null: false
      add :description, :text
      add :added_by_id, references(:users, type: :binary_id, on_delete: :nilify_all)

      timestamps(type: :utc_datetime)
    end

    create unique_index(:ip_whitelist, [:ip_or_cidr])
    create index(:ip_whitelist, [:added_by_id])
  end
end
