Migrations: Version Control for Your Database
Create and manage database tables using Laravel migrations step by step.
Daniel Scott
Nov 15, 2025
15.6k437
Migrations allow you to define database structure in code and keep it versioned.
Create a migration
php artisan make:migration create_posts_table
Example migration
public function up(): void {
Schema::create('posts', function (Blueprint $table) {
$table->id();
$table->string('title');
$table->text('body');
$table->timestamps();
});
}
public function down(): void {
Schema::dropIfExists('posts');
}
Run migrations
php artisan migrate
Migration flow
flowchart TD
A[Migration file] --> B[php artisan migrate]
B --> C[(Database tables)]
In the next tutorial, we will work with Eloquent models to interact with this data.
#Laravel#Database#Migrations#Beginner