T
T
Tikhon Ermakov2020-08-10 14:01:56
Laravel
Tikhon Ermakov, 2020-08-10 14:01:56

What is the correct way to add a foreign key?

I couldn't come up with a name for the table, I decided to add these two fields to the user table :)

subscription_id
subscription_ends_at


I want to add FK to subscription_id , but the problem is that the subscriptions table has not yet been created during migration.

Of course, you can make sure that the subscriptions table is created before the user table, but it seems to me that this is already a crutch.
What can be done?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question