Today’s Offer Enroll today and get access to premium content.
App Store Google Play
Intermediate

How do you create a migration in Laravel?

Migrations in Laravel are like version control for your database, allowing you to define and modify database tables easily.

To create a migration, follow these steps:

  1. Open your terminal.
  2. Run the command: php artisan make:migration create_users_table.
  3. Define the schema in the generated migration file located in database/migrations.

For instance, to create a users table, you would write:

Schema::create('users', function (Blueprint $table) { $table->id(); $table->string('name'); $table->timestamps(); });