Skip to content
This repository has been archived by the owner on Oct 5, 2021. It is now read-only.

User token relationship .onDelete('CASCADE') to blueprint #40

Open
McSneaky opened this issue Jun 9, 2019 · 0 comments
Open

User token relationship .onDelete('CASCADE') to blueprint #40

McSneaky opened this issue Jun 9, 2019 · 0 comments
Labels

Comments

@McSneaky
Copy link

McSneaky commented Jun 9, 2019

Currently when I try to delete user I get error:

ERROR: update or delete on table "users" violates foreign key constraint "tokens_user_id_foreign" on table "tokens"

I usually modify token migration to include .onDelete('CASCADE') to user and token relation in https://github.com/adonisjs/adonis-api-app/blob/master/database/migrations/1503250034280_token.js#L10

Then I don't have to worry about clearing user tokens before I delete user itself.

Perhaps it can added into blueprint(s) by default?
Or will it cause problems with some databases? 🤔

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

1 participant