Answers for "php migration"

PHP
21

laravel foreign key

Schema::table('posts', function (Blueprint $table) {
    $table->unsignedBigInteger('user_id');

    $table->foreign('user_id')->references('id')->on('users');
});
OR
Schema::table('posts', function (Blueprint $table) {
    $table->foreignId('user_id')->constrained();
});
Posted by: Guest on December-09-2020
1

laravel migration rollback

To rollback one step:

php artisan migrate:rollback

To rollback multiple steps:

php artisan migrate:rollback --step=[x]
  
To drop all tables and reload all migrations:

php artisan migrate:fresh
Posted by: Guest on December-01-2020
2

php migrate

php artisan make:migration create_person_table
Posted by: Guest on September-09-2021
0

php artisan migration refresh

php artisan migrate:refresh --step=1
Posted by: Guest on January-06-2021
2

php artisan see last migration

php artisan migrate:status
Posted by: Guest on May-06-2020

Browse Popular Code Answers by Language