create database from migration laravel code example

Example 1: laravel migrate database

php artisan migrate

Example 2: create laravel migration

php artisan make:migration create_users_table

Example 3: laravel migration foreign key 5.6

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

    $table->foreign('user_id')->references('id')->on('users');
});

Example 4: laravel migration

php artisan make:migration create_users_table --create=users

php artisan make:migration add_votes_to_users_table --table=users

Example 5: create database from migration laravel for all

php artisan migrate:refresh

php artisan migrate:refresh --seed

Example 6: create database from migration laravel for all

php artisan migrate --force

Tags:

Sql Example