Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
begedin committed Oct 3, 2017
1 parent 159c8ec commit 0a8a615
Show file tree
Hide file tree
Showing 4 changed files with 121 additions and 101 deletions.
1 change: 1 addition & 0 deletions lib/code_corps/accounts/accounts.ex
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ defmodule CodeCorps.Accounts do
|> Changeset.change(params |> Adapters.User.from_github_user())
|> Changeset.put_change(:context, "github")
|> Changeset.unique_constraint(:email)
|> Changeset.unique_constraint(:github_id)
|> Changeset.validate_inclusion(:type, ["bot", "user"])
end
end
1 change: 1 addition & 0 deletions lib/code_corps/github/user.ex
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ defmodule CodeCorps.GitHub.User do
|> Changeset.change(user_payload |> UserAdapter.from_github_user)
|> Changeset.put_change(:github_auth_token, access_token)
|> Changeset.validate_required([:github_auth_token, :github_avatar_url, :github_id, :github_username])
|> Changeset.unique_constraint(:github_id)

multi =
Multi.new
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
defmodule CodeCorps.Repo.Migrations.AddUniqueConstraintToUsersGithubId do
use Ecto.Migration

def change do
create index(:users, [:github_id], unique: true)
end
end

0 comments on commit 0a8a615

Please sign in to comment.