In this tutorial learn how to create/generate table in database using php artisan migrate function in laravel, How to create a table into database using php artisan make:migration, let's go step by step.
To create a migration, use the make:migration
1. Create Table
2. Migration structure in project_name/database/migration/2019_10_12_000000_create_users_table.php
Within both of these methods you may use the Laravel schema builder to expressively create and modify tables. To learn about all of the methods available on the Schema builder
3. Running Migrations for creating a tables into the database, make sure, database connection details added in .env
To run all migrations, execute the migrate Artisan command:
To create a migration, use the make:migration
php artisan make:migration create_users_table = users
2. Migration structure in project_name/database/migration/2019_10_12_000000_create_users_table.php
Within both of these methods you may use the Laravel schema builder to expressively create and modify tables. To learn about all of the methods available on the Schema builder
<?php use Illuminate\Support\Facades\Schema; use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Migrations\Migration; class CreateUsersTable extends Migration { /** * Run the migrations. * * @return void */ public function up() { Schema::create('users', function (Blueprint $table) { $table->bigIncrements('id'); $table->string('name'); $table->string('email')->unique(); $table->timestamp('email_verified_at')->nullable(); $table->string('password'); $table->rememberToken(); $table->timestamps(); }); } /** * Reverse the migrations. * * @return void */ public function down() { Schema::dropIfExists('users'); } }
3. Running Migrations for creating a tables into the database, make sure, database connection details added in .env
To run all migrations, execute the migrate Artisan command:
php artisan migrate
OR use force if not work just migrationphp artisan migrate --force
Very good brief and this post helped me alot. Say thank you I searching for your facts. Thanks for sharing with us!
ReplyDeletewordpress support service
custom wordpress development
wordpress theme development
wordpress plugin development