Skip to content

Instantly share code, notes, and snippets.

@bnhansn
Created October 21, 2016 19:00
Show Gist options
  • Save bnhansn/12154286bc32ef53d8d4722e7bd6a97d to your computer and use it in GitHub Desktop.
Save bnhansn/12154286bc32ef53d8d4722e7bd6a97d to your computer and use it in GitHub Desktop.
defmodule Sling.Repo.Migrations.CreateUserRoom do
use Ecto.Migration
def change do
create table(:user_rooms) do
add :user_id, references(:users, on_delete: :nothing), null: false
add :room_id, references(:rooms, on_delete: :nothing), null: false
timestamps()
end
create index(:user_rooms, [:user_id])
create index(:user_rooms, [:room_id])
create index(:user_rooms, [:user_id, :room_id], unique: true)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment