architex/priv/repo/migrations/20210623145023_add_devices_table.exs
2021-06-26 00:29:33 +02:00

19 lines
550 B
Elixir

defmodule MatrixServer.Repo.Migrations.AddDevicesTable do
use Ecto.Migration
def change do
create table(:devices, primary_key: false) do
add :device_id, :string, primary_key: true, null: false
add :access_token, :string
add :display_name, :string
add :localpart,
references(:accounts, column: :localpart, on_delete: :delete_all, type: :string),
primary_key: true,
null: false
end
# Compound primary already indexes device_id.
create index(:devices, [:localpart])
end
end