Laravel migrate

When I try to run php artisan migrate, I encounter the error 2024_02_14_184516_create_employees_table [1] 73367 segmentation fault php artisan migrate, and in the code I've written as follows:
public function up(): void
{
Schema::create('employees', function (Blueprint $table) {
$table->id();
$table->foreignId('country_id')->constrained()->cascadeOnDelete();
$table->foreignId('state_id')->constrained()->cascadeOnDelete();
$table->foreignId('city_id')->constrained()->cascadeOnDelete();
$table->foreignId('department_id')->constrained()->cascadeOnDelete();
$table->string('first_name');
$table->string('last_name');
$table->string('address');
$table->string('zip_code');
$table->date('birth_date');
$table->date('date_hired');
$table->timestamps();
});
}
public function up(): void
{
Schema::create('employees', function (Blueprint $table) {
$table->id();
$table->foreignId('country_id')->constrained()->cascadeOnDelete();
$table->foreignId('state_id')->constrained()->cascadeOnDelete();
$table->foreignId('city_id')->constrained()->cascadeOnDelete();
$table->foreignId('department_id')->constrained()->cascadeOnDelete();
$table->string('first_name');
$table->string('last_name');
$table->string('address');
$table->string('zip_code');
$table->date('birth_date');
$table->date('date_hired');
$table->timestamps();
});
}
7 Replies
Douglas Silvestrini
1. Make sure the tables (countries, states, cities and departments) exists before that table employees... 2. I like to specify the table at constrained method
$table->foreignId('country_id')->constrained('countries')->cascadeOnDelete();
$table->foreignId('country_id')->constrained('countries')->cascadeOnDelete();
3. Try
php artisan migrate:fresh
php artisan migrate:fresh
Batuhan
Batuhan4mo ago
https://youtu.be/6c4jVLWmDYU?t=778 I'm using this video to learn, but apparently he skipped some parts. Is there a training series you recommend? Please help me. I need to learn. I can also buy a series from Udemy, as long as you help me. @Douglas Silvestrini 🙏
Douglas Silvestrini
I have, but these classes are in portuguese I can recommend you some channels on Youtube about Laravel
Douglas Silvestrini
Code With Dary
YouTube
Laravel Tutorial for Beginners | How to Learn Laravel | Complete La...
This tutorial shows you how to learn Laravel 9. It is a full Laravel 9 Tutorial for Beginners where you learn the most important Laravel topics to get started. Keep in mind that this tutorial is using a Laravel version prior to 9.19.0, which means that Webpack is being used and not Laravel Vite – Want to learn the most popular PHP framework? Lar...
Douglas Silvestrini
Read a lot the Laravel's documentation, it's your best friend Use sqlite as database, it's more simple You can use the php artisan serve for testing you application, or learn to use Laragon as local server Good luck
Batuhan
Batuhan4mo ago
too muuchh thanks
Want results from more Discord servers?
Add your server
More Posts