Skip to content

Instantly share code, notes, and snippets.

@bnhansn
Created October 22, 2016 12:03
Show Gist options
  • Save bnhansn/dbeb29339f0736139cd62876bad294fa to your computer and use it in GitHub Desktop.
Save bnhansn/dbeb29339f0736139cd62876bad294fa to your computer and use it in GitHub Desktop.
defmodule Sling.Repo.Migrations.CreateMessage do
use Ecto.Migration
def change do
create table(:messages) do
add :text, :string, null: false
add :room_id, references(:rooms, on_delete: :nothing), null: false
add :user_id, references(:users, on_delete: :nothing), null: false
timestamps()
end
create index(:messages, [:room_id])
create index(:messages, [:user_id])
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment