【发布时间】:2015-01-08 08:52:44
【问题描述】:
我是 Laravel 的新手,现在使用 v4.2。我想使用迁移制作一张桌子。一切都是正确的。迁移也产生了。但是在 db 中除了迁移表之外没有找到表。首先在命令提示符中我写了php artisan migrate:make create_users_table。然后迁移表被装箱。然后在迁移文件中我写了以下代码
public function up()
{
Schema::create('users', function($table)
{
$table->increments('id');
$table->string('username');
$table->string('password');
$table->timestamps();
});
}
public function down()
{
Schema::drop('users');
}
然后,如果我尝试 php artisan migrate,命令提示符不会说要迁移。
【问题讨论】:
-
推荐,在你的 down 函数中使用
Schema::dropIfExists('users');。另外,您的app->config->app.php和app->config->database.php是什么样的?您是否使用了正确的连接设置? -
app->config->app.php 密钥是自动设置的,app->config->database.php 我设置了我的 da 名称、主机名和用户名。我现在在本地工作。
-
谢谢蒂姆·刘易斯。它现在可以工作了。
-
@Salman:- 添加这个问题的答案,然后接受并关闭问题