【发布时间】:2017-02-21 01:42:26
【问题描述】:
我正在使用 Laravel 5.2。我确实使用php artisan make:migration create_users_table 命令创建了迁移文件。文件创建成功,我确实使用此代码更新了文件:
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateUsersTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('users', function (Blueprint $table) {
$table->increments('id');
$table->integer('partner_id');
$table->string('social_id');
$table->integer('device_id');
$table->integer('gcm_id');
$table->integer('user_role');
$table->string('social_media');
$table->string('display_name');
$table->string('first_name');
$table->string('last_name');
$table->integer('status');
$table->string('email')->unique();
$table->string('password');
$table->string('profile_pic');
$table->string('gender');
$table->float('height');
$table->float('weight');
$table->string('dob');
$table->bigInteger('mobile');
$table->string('city');
$table->string('state');
$table->integer('zip');
$table->string('country');
$table->float('latitude');
$table->float('longitude');
$table->float('gps_status');
$table->string('favorite_movie');
$table->string('favorite_food');
$table->string('favorite_weather');
$table->integer('login_status');
$table->string('active');
$table->string('token');
$table->rememberToken();
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('users');
}
}`
为了运行迁移,我使用这个“php artisan migrate”命令。并发生错误
'迁移表创建成功。
[Illuminate\Database\QueryException] SQLSTATE[HY000]:常规 错误:1025 重命名 '.\laravel\users' 时出错 '.\laravel#sql2-1d88-70' (errno: 190 - Operation not allowed when innodb_forced_recovery > 0) (SQL: alter table
usersadd uniqueusers_email_unique([PDOException] SQLSTATE[HY000]: 一般错误: 1025 Error on 将 '.\laravel\users' 重命名为 '.\laravel#sql2-1d88-70' (errno: 190 - innodb_forced_recovery > 0)'时不允许操作
之后我使用了回滚命令php artisan migrate:rollback,但消息显示没有回滚,当我想创建第二个表时,消息显示the user table already exist。
【问题讨论】:
-
你试过
php artisan migrate:fresh吗?看起来您的旧数据库仍然存在
标签: laravel migration laravel-artisan