Ecto: Drop Constraint Not Working in Migration

Created on 3 Feb 2017  路  1Comment  路  Source: elixir-ecto/ecto

Precheck

  • Do not use the issues tracker for help or support requests (try Stack Overflow, IRC or mailing lists, etc).
  • For proposing a new feature, please start a discussion on elixir-ecto.
  • For bugs, do a quick search and make sure the bug has not yet been reported.
  • Finally, be nice and have fun!

Environment

  • Elixir version (elixir -v): 1.3.1
  • Database and version (PostgreSQL 9.4, MongoDB 3.2, etc.): 9.5.4
  • Ecto version (mix dips): 2.1.2
  • Database adapter and version (mix dips): postgrex 0.13.0
  • Operating system: OS X 10.11.6

Current behavior

def down do
    drop constraint(:users, "must_belong_to_company_or_organization")
    Repo.update_all(User, set: [company_id: nil, organization_id: nil])
 end
** (Postgrex.Error) ERROR 23514 (check_violation): new row for relation "users" violates check constraint "must_belong_to_company_or_organization"

    table: users
    constraint: must_belong_to_company_or_organization

Expected behaviour

I expect the constraint to be dropped before the update is executed.

Most helpful comment

Migration instructions are accumulated. If you want to execute them before the end of the migration, you need to call flush().

>All comments

Migration instructions are accumulated. If you want to execute them before the end of the migration, you need to call flush().

Was this page helpful?
0 / 5 - 0 ratings

Related issues

stavro picture stavro  路  4Comments

yordis picture yordis  路  4Comments

fuelen picture fuelen  路  3Comments

jonasschmidt picture jonasschmidt  路  4Comments

brandonparsons picture brandonparsons  路  3Comments