Dorokhov.codes
Migrations
Migrations are located in database/migrations/*.php
. Example:
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('users', function (Blueprint $table) {
$table->id();
$table->string('name');
$table->string('email')->unique();
$table->timestamp('email_verified_at')->nullable();
$table->string('password');
$table->rememberToken();
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('users');
}
};
Apply migrations:
php artisan migrate
Create a migration:
php artisan make:migration create_users_table
Rollback the last applied migrations:
php artisan migrate:rollback