I\'m trying to run the migration (see below) and seed the database, but when I run
php artisan migrate --seed
I get this error:
<
Here is what works for me every time.
When you're adding the foreign key, make sure to add cascade.
the syntax is like this
$table->foreign('column')->references('id')->on('table_name')->onDelete('cascade');
Make sure to replace id with whatever field is applicable for you.
Now before running the seeding add this instead of trucate
DB::statement('DELETE FROM table_name');
It will delete all the data. Hope this helps.