1php artisan make:migration create_table_name --create=tablel_name
2php artisan migrate
1Schema::table('posts', function (Blueprint $table) {
2 $table->unsignedBigInteger('user_id');
3
4 $table->foreign('user_id')->references('id')->on('users');
5});
6OR
7Schema::table('posts', function (Blueprint $table) {
8 $table->foreignId('user_id')->constrained();
9});
1// use the make:migration Artisan command to generate a database migration
2php artisan make:migration create_flights_table
3
4// use --create to indicate whether the migration will be creating a new table
5php artisan make:migration create_flights_table --create=flights
6
7// use --table to indicate the table name
8php artisan make:migration add_destination_to_flights_table --table=flights
1php artisan make:migration add_votes_to_users_table --table=users
2
3php artisan make:migration create_users_table --create=users
1php artisan make:migration create_employeeDetails_table --create=Employee
2//goto create_employeeDetails_table file and add fields in table
3php artisan migrate