Nếu bạn muốn tạo một bảng khác, chỉ cần tạo một tệp di chuyển mới. Nó sẽ hoạt động.
Nếu bạn tạo một di chuyển có tên users_tablevới id, first_name, last_name. Bạn có thể tạo một tệp di chuyển như
public function up()
{
Schema::create('users', function (Blueprint $table) {
$table->increments('id');
$table->string('first_name',255);
$table->string('last_name',255);
$table->rememberToken();
$table->timestamps();
});
}
public function down()
{
Schema::dropIfExists('users');
}
Nếu bạn muốn thêm một tệp khác như "trạng thái" mà không cần di chuyển: refresh. Bạn có thể tạo một tệp di chuyển khác như "add_status_filed_to_users_table"
public function up()
{
Schema::table('users', function($table) {
$table->integer('status');
});
}
Và đừng quên thêm tùy chọn khôi phục:
public function down()
{
Schema::table('users', function($table) {
$table->dropColumn('status');
});
}
Và khi bạn chạy di chuyển với php artitsan migration, Nó chỉ di chuyển tệp di chuyển mới.
Nhưng nếu bạn thêm "trạng thái" đã nộp vào tệp kiểm duyệt đầu tiên (users_table) và chạy quá trình di chuyển. Không có gì để di chuyển. Bạn cần chạyphp artisan migrate:refresh .
Hy vọng điều này giúp đỡ.