Php Laravel默认用户表
我使用Laravel5.2并希望更改默认用户表的列。我写 在CreateUsersTable中Php Laravel默认用户表,php,laravel,Php,Laravel,我使用Laravel5.2并希望更改默认用户表的列。我写 在CreateUsersTable中 public function up() { Schema::create('users', function (Blueprint $table) { $table->increments('id'); $table->string('name'); $table->string('email')->uniq
public function up()
{
Schema::create('users', function (Blueprint $table) {
$table->increments('id');
$table->string('name');
$table->string('email')->unique();
$table->string('password');
$table->rememberToken();
$table->timestamps();
});
Schema::table('users', function ($table) {
$table->string('role');
$table->string('info');
$table->string('age');
$table->string('hobies');
$table->string('job');
});
}
我在GitBash中运行了这些命令,但用户表没有改变
php artisan migrate:refresh
php artisan migrate
如何解决此问题?您应该在运行
php artisan migrate
命令后运行composer dumpauto-o
,以注册新的迁移,以便回滚它们
试试看。如果不起作用,请尝试删除所有表,包括migrations
,然后运行以下命令:
php artisan migrate:install
您应该在运行
php artisan migrate
命令后运行composer dumpauto-o
,以注册新的迁移,以便回滚它们
试试看。如果不起作用,请尝试删除所有表,包括migrations
,然后运行以下命令:
php artisan migrate:install
您只需更改它在
Schema::create
中的内容,并删除您的Schema::table
然后,您需要实现tourdown()
mehod并添加Schema::drop('users')代码>以便在运行migrate:refresh
时删除表
您可以阅读laravel文档中的“数据库迁移”以了解更多详细信息。您只需更改Schema::create
中的内容并删除Schema::table
然后,您需要实现tourdown()
mehod并添加Schema::drop('users')代码>以便在运行migrate:refresh
时删除表
您可以阅读laravel文档中的“数据库迁移”了解更多详细信息。创建新的迁移文件并执行类似操作
public function up() {
DB::statement('ALTER TABLE user ADD some_field INT');// your query here
}
php artisan migrate
创建新的迁移文件并执行如下操作
public function up() {
DB::statement('ALTER TABLE user ADD some_field INT');// your query here
}
php artisan migrate
删除第一条语句,只保留最后一条。
然后运行php artisan migrate:refresh删除第一条语句,只保留最后一条语句。
然后运行php artisan迁移:刷新