How to make a Foreign Key field non-nullable with a default
Non-nullable foreign keys require the ID of the default object. Learn how to create a custom migration to create a default.
Non-nullable foreign keys require the ID of the default object. Learn how to create a custom migration to create a default.
This post gives an example of how to add foreign keys to your project. Using blog posts and categories as our example, we will add a foreign key and allow users to view posts by category.