code-corps/code-corps-api

View on GitHub
priv/repo/migrations/20171114033357_add_unique_constraint_for_project_github_repo_and_project.exs

Summary

Maintainability
Test Coverage
defmodule CodeCorps.Repo.Migrations.AddUniqueConstraintForProjectGithubRepoAndProject do
  use Ecto.Migration

  def up do
    drop_if_exists index(:project_github_repos, [:project_id, :github_repo_id], unique: true)
    drop_if_exists index(:project_github_repos, [:github_repo_id], unique: true)
    create unique_index(:project_github_repos, [:github_repo_id])
  end

  def down do
    drop_if_exists index(:project_github_repos, [:github_repo_id], unique: true)
    create unique_index(:project_github_repos, [:project_id, :github_repo_id])
  end
end