Migration là định nghĩa schema database được quản lý bằng version control. Tạo bằng php artisan make:migration create_users_table. Định nghĩa bảng trong method up(): Schema::create("users", function(Blueprint $table) { $table->id(); $table->string("name"); ... }) và rollback trong down(). Chạy tất cả migration bằng php artisan migrate.
Ưu điểm: theo dõi thay đổi schema trong git, rollback dễ dàng, nhất quán giữa các môi trường, tài liệu hóa cấu trúc bảng. Migration giải quyết vấn đề đồng bộ database trong team và khi deploy. Lưu ý: dùng $table->id() (Laravel 11 convention, tương đương bigIncrements) thay vì $table->increments("id") cũ.
Migrations are version-controlled database schema definitions. Create with php artisan make:migration create_users_table. Define tables in up() method: Schema::create("users", function(Blueprint $table) { $table->id(); $table->string("name"); ... }) and rollback in down(). Run all pending with php artisan migrate.
Advantages: track schema changes in version control, easy rollback, consistent across environments, document table structure. Migrations solve database synchronization problems across team and deployments. Use $table->id() (modern Laravel convention, shortcut for bigIncrements) instead of the older $table->increments("id").