teamspaces / web

Web & API – Spaces is knowledge management for teams.
0 stars 0 forks source link

Remove user reference from invitations #174

Closed emmanuelmillionaer closed 7 years ago

emmanuelmillionaer commented 7 years ago

What

Before, when deleting an user, who already created invitations, this table constraint error got raised:

User.last.destroy
ActiveRecord::InvalidForeignKey: PG::ForeignKeyViolation: ERROR:  update or delete on table "users" violates foreign key constraint "fk_rails_7eae413fe6" on table "invitations"
DETAIL:  Key (id)=(26) is still referenced from table "invitations".
: DELETE FROM "users" WHERE "users"."id" = $1
    from /bundler-cache/gems/activerecord-5.0.0/lib/active_record/connection_adapters/postgresql_adapter.rb:598:in `async_exec'
    from /bundler-cache/gems/activerecord-5.0.0/lib/active_record/connection_adapters/postgresql_adapter.rb:598:in `block in exec_no_cache'
    from /bundler-cache/gems/activerecord-
        ........