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

  def change do
    create table(:sites, 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 :parent_site_id, references(:sites, type: :binary_id, on_delete: :delete_all)
      add :name, :string, null: false
      add :description, :text
      add :location, :string

      timestamps(type: :utc_datetime)
    end

    create index(:sites, [:organization_id])
    create index(:sites, [:parent_site_id])
  end
end
