Nov 7 · 1 min read
I agree that you should think about your database on paper first, but eventualy if your app is evolving you may need to add foreign keys after you create your “types” tables.
So you can create a new migration or even set the foreign key in the “types” tables. Like so:
Schema::create('services', function (Blueprint $table) {
$table->increments('id');
...
});Schema::table('messages', function (Blueprint $table) {
$table->foreign('service_id')
->references('id')
->on('services')
->onDelete('cascade');
});
