当我迁移时,我收到此错误还有一件事,用户表有两个迁移文件,一个用于创建,另一个用于更改以下代码 ID 用于更改表。因此,我无法进一步迁移表,如果可能,请提供任何 tuts 链接。移民
这是我的迁移代码,用于更改表
public function up()
{
Schema::table('users', function (Blueprint $table) {
$table->integer('active')->after('id')->unsigned()->nullable();
$table->integer('status')->after('active')->unsigned()->nullable();
$table->string('sysid')->after('status')->nullable();
$table->string('workarea', 200)->after('sysid')->nullable();
$table->string('first', 50)->after('name');
$table->string('last', 50)->after('first');
$table->text('bio')->nullable()->after('last');
$table->string('cover_image', 50)->nullable()->after('bio');
$table->json('score')->nullable()->after('cover_image');
$table->integer('language_id')->nullable()->unsigned();
$table->integer('company_id')->nullable()->unsigned();
$table->integer('team_id')->nullable()->unsigned();
// $table->json('avatar')->nullable();
$table->text('avatar')->nullable();
$table->foreign('language_id')->references('id')->on('languages');
$table->foreign('company_id')->references('id')->on('companies');
$table->foreign('team_id')->references('id')->on('teams');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('users', function (Blueprint $table) {
$table->dropForeign('users_language_id_foreign');
$table->dropForeign('users_company_id_foreign');
$table->dropForeign('users_team_id_foreign');
$table->dropColumn('active');
$table->dropColumn('status');
$table->dropColumn('language_id');
$table->dropColumn('company_id');
$table->dropColumn('team_id');
$table->dropColumn('first');
$table->dropColumn('last');
$table->dropColumn('bio');
$table->dropColumn('cover_image');
$table->dropColumn('score');
});
}
错误接近cover_image 不知道我做错了什么,提前致谢
你的错误在这一行
$table->json('score')->nullable()->after('cover_image');
更改您的数据类型,如果您希望它作为整数,它会像这样正常工作
public function up()
{
Schema::table('users', function (Blueprint $table) {
$table->integer('active')->after('id')->unsigned()->nullable();
$table->integer('status')->after('active')->unsigned()->nullable();
$table->string('sysid')->after('status')->nullable();
$table->string('workarea', 200)->after('sysid')->nullable();
$table->string('first', 50)->after('name');
$table->string('last', 50)->after('first');
$table->text('bio')->nullable()->after('last');
$table->string('cover_image', 50)->nullable()->after('bio');
$table->integer('score')->nullable()->after('cover_image');
$table->integer('language_id')->nullable()->unsigned();
$table->integer('company_id')->nullable()->unsigned();
$table->integer('team_id')->nullable()->unsigned();
// $table->json('avatar')->nullable();
$table->text('avatar')->nullable();
$table->foreign('language_id')->references('id')->on('languages');
$table->foreign('company_id')->references('id')->on('companies');
$table->foreign('team_id')->references('id')->on('teams');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('users', function (Blueprint $table) {
$table->dropForeign('users_language_id_foreign');
$table->dropForeign('users_company_id_foreign');
$table->dropForeign('users_team_id_foreign');
$table->dropColumn('active');
$table->dropColumn('status');
$table->dropColumn('language_id');
$table->dropColumn('company_id');
$table->dropColumn('team_id');
$table->dropColumn('first');
$table->dropColumn('last');
$table->dropColumn('bio');
$table->dropColumn('cover_image');
$table->dropColumn('score');
});
}
认为它对你有用
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句