First of all, make sure that the database link in the Laravel. env file is created, and here I'm using the MySQL database
1 db_connection=mysql // database 2 db_host=127.0.0.1 // Server IP Address 3 db_port=3306 // database Port 4 db_database=larvael54 // Database name 5 db_username=root // database user name 6 db_password=root // Database Password
Here I'm using the PHP Storm command line input to create the migration command, such as creating the Users table
PHP Artisan make:migration create_users_table
Note: Creating a migration file named Create_ table name _table creates a successful creation in the Migrations directory under the database directory.
2017_12_6_205846_create_users_table.php file, open file input code
<?PHP UseIlluminate\support\facades\schema; UseIlluminate\database\schema\blueprint; Useilluminate\database\migrations\migration;classCreateuserstableextendsmigration{/** * Run the migrations. * * @return void*/ Public functionUp () {Schema:: Create (' users ',function(Blueprint$table) {//Here is the field property of the table you want to create$table->increments (' id '); $table-string(' Name '); $table-string(' email ')Unique (); $table-string(' Password '); $table-Remembertoken (); $table-timestamps (); }); } /** * Reverse the migrations. * * @return void*/ Public functionDown () {Schema::d ropifexists (' users '); }}
When the file is created successfully, enter it on the PHP storm command line
PHP Artisan Migrate
After execution completes, the build table succeeds.
laravel5.4 using Migration database migration to build a table