Remove the reference to the User, who created the Invitation, from the Invitations-Model.
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-
........
What
Rename Invitation columns
Remove the reference to the User, who created the Invitation, from the Invitations-Model.
Before, when deleting an user, who already created invitations, this table constraint error got raised: