我目前正在从这部视频中学习
https://laracasts.com/series/laravel-from-scratch-2018/episodes/7
关于laravel中的数据库迁移。 我输入了控制台:
php artisan make:migration create_projects_table
就像视频中的老师一样,在某种程度上,我在migrations文件夹中得到一个空的方法定义。
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateProjectsTable extends Migration
{
public function up()
{
//should contain Schema::create but it is empty
}
public function down()
{
}
}
我做错了什么?我按照视频中的所有说明进行操作。
答案 0 :(得分:1)
php artisan make:migration create_projects_table --create = projects
编辑:它确实可以在不添加参数的情况下运行: https://github.com/laravel/framework/blob/854e6d1d001f5e9a6d1376d2284eaa99b0c1e443/src/Illuminate/Database/Console/Migrations/MigrateMakeCommand.php#L88
// Next, we will attempt to guess the table name if this the migration has
// "create" in the name. This will allow us to provide a convenient way
// of creating migrations that create new tables for the application.
if (! $table) {
[$table, $create] = TableGuesser::guess($name);
}
在这里您可以看到表格名称应与(\w+)
模式匹配
答案 1 :(得分:1)
在根文件夹上使用此命令
php artisan make:migration create_projects_table --create=projects //create only Migration file
php artisan make:model Project -m //Create Migration, Model file
php artisan make:model Project -mcr //For Create Migration,Model,Controller file