的make:migration
命令只是創建一個新的遷移來自模板的文件。要實際定義遷移,您通常必須編輯該文件。所以你的情況,你會做到這一點:
php artisan make:migration create_two_tables --create="projects"
然後打開***_create_two_tables.php
遷移文件,並添加第二個表:
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('projects', function(Blueprint $table)
{
});
Schema::create('tasks', function(Blueprint $table)
{
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('projects');
Schema::drop('tasks');
}
通常你也想實際列添加到您的表。而你做的Schema::create
閉包:
Schema::create('projects', function(Blueprint $table)
{
$table->increments('id');
$table->string('name');
// and so on
});
Read more about creating tables with the Schema Builder here
我已經這樣做了,我希望通過命令提示符來創建這個表格,是否有這種可能性 – Akilsree1 2015-02-24 08:11:04
不是沒有你自己的命令。但難以打開文件並複製粘貼+更改表名? – lukasgeiter 2015-02-24 08:13:34