analytics/priv/repo/migrations/20190109173917_create_sites.exs

31 lines
612 B
Elixir
Raw Normal View History

2019-09-02 14:29:19 +03:00
defmodule Plausible.Repo.Migrations.CreateSites do
use Ecto.Migration
def change do
create table(:users) do
add :email, :string, null: false
timestamps()
end
create unique_index(:users, :email)
create table(:sites) do
add :domain, :string, null: false
timestamps()
end
create unique_index(:sites, :domain)
create table(:site_memberships) do
add :site_id, references(:sites), null: false
add :user_id, references(:users), null: false
timestamps()
end
create unique_index(:site_memberships, [:site_id, :user_id])
end
end