559 B · text History 4b6fe3b
defmodule OhMyExOhIrcd.Repo.Migrations.CreateChannels do
  use Ecto.Migration

  def change do
    create table(:channels) do
      # Stored downcased; original-case name is not preserved here (IRC
      # channel names are case-insensitive anyway).
      add :name, :string, null: false
      add :founder_user_id, references(:users, on_delete: :nilify_all)
      add :topic, :text, default: "", null: false

      timestamps(type: :utc_datetime)
    end

    create unique_index(:channels, [:name])
    create index(:channels, [:founder_user_id])
  end
end