Hướng dẫn php artisan make migrate
Ngày đăng:
19/09/2022
Trả lời:
0
Lượt xem:
105
Migration là gì?
Tạo dữ liệu với Migration
cd C:\xampp\htdocs\myproject\
php artisan make:migration create_news_table
Dòng lệnh trên thực thi sẽ cho ta kết quả sau:
increments('id'); $table->timestamps(); }); } /** * Reverse the migrations. * * @return void */ public function down() { Schema::dropIfExists('news'); } }
Với nội dung trên, ta đã có thể tạo bảng news với 1 cột là id, để có thể nhiều cột hơn ta thêm trực tiếp vào bên trong function up(): increments('id'); $table->string('headline'); $table->string('email'); $table->timestamps(); }); } /** * Reverse the migrations. * * @return void */ public function down() { Schema::dropIfExists('news'); } }
Xử lý lỗi khi chạy lệnh Migration
|