【发布时间】:2017-10-18 16:55:54
【问题描述】:
我正在使用 laravel 将列位置添加到用户表中。我创建了一个名为 2017_05_18_025207_add_username_field_to_users_table 的新迁移 .. 并在 up() 和 down() 中对其进行了描述架构和全部修改。但是,当我尝试使用 PHP artisan migrate 迁移它时。它没有反映在数据库中。
class AddUsernameFieldToUsersTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('users', function(Blueprint $table)
{
$table->string('place');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('users', function(Blueprint $table)
{
$table->dropColumn('place');
});
}
}
这段代码是我在新迁移中写的 .
【问题讨论】:
-
您在尝试迁移时是否看到任何错误?运行后它是否也出现在迁移表中?
-
不,它没有出现在我的迁移表中。并且没有发现错误。事实上,在 cmd 中我收到了这条消息 Migrating: 2017_05_18_025207_add_username_field_to_users_table Migrated: 2017_05_18_025207_add_username_field_to_users_table
-
您用来连接数据库的任何客户端都可能存在缓存问题吗?尝试 sql 命令
describe users;以确保该列实际上没有被添加。 -
@user3158900 感谢您的帮助.. 它完成了.. 我不知道出了什么问题,但我回滚并尝试了 2 -3 次终于添加了该列。
标签: php mysql database laravel migration