summaryrefslogtreecommitdiff
path: root/priv/repo/migrations/20230529193504_add_bots.exs
blob: 3f48c0af000a7e2b23a130cc08bd67b165600db5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
defmodule Chessh.Repo.Migrations.AddBots do
  use Ecto.Migration

  def change do
    create table(:bots) do
      add(:name, :citext, null: false)
      add(:webhook, :string, null: false)
      add(:token, :string, null: false)
      add(:public, :boolean, null: false)
      add(:player_id, references(:players), null: false)

      timestamps()
    end

    create(unique_index(:bots, [:name]))
    create(unique_index(:bots, [:token]))

    alter table(:games) do
      add(:bot_id, references(:bots), null: true)
    end
  end
end