錯誤使用消息 'SQLSTATE[HY000] 照亮/數據庫/QueryException:一般錯誤:1 表配置文件沒有名為標題的列(SQL:插入“配置文件”(“標題”,“描述”,“user_id”,“updated_at”,“ create_at") 值 (asd, 123123, 2, 2020-07-31 10:19:03, 2020-07-31 10:19:03))'這是我在 '$profile -> save();' 時遇到的錯誤 我正在根據以下鏈接學習 Laravel: https://www.youtube.com/watch?v =ImtZ5yENzgE&list=WL&index=45&t=81s這是 2020_07_31_074115_create_profiles_table.php { Schema::create('profiles', function (Blueprint $table) { $table->bigIncrements('id'); $table->unsignedBigInteger('user_id'); $table->string('title')->nullable(); $table->text('description')->nullable(); $table->string('url')->nullable(); $table->timestamps(); $table->index('user_id'); //FK }); } /** * Reverse the migrations. * * @return void */ public function down() { Schema::dropIfExists('profiles'); }這是 2014_10_12_000000_create_users_table.php<?phpuse Illuminate\Database\Migrations\Migration;use Illuminate\Database\Schema\Blueprint;use Illuminate\Support\Facades\Schema;class CreateUsersTable extends Migration{ /** * Run the migrations. * * @return void */ public function up() { Schema::create('users', function (Blueprint $table) { $table->bigIncrements('id'); $table->string('name'); $table->string('email')->unique(); $table->string('username')->unique(); $table->timestamp('email_verified_at')->nullable(); $table->string('password'); $table->rememberToken(); $table->timestamps(); }); } /** * Reverse the migrations. * * @return void */ public function down() { Schema::dropIfExists('users'); }}
1 回答

繁星coding
TA貢獻1797條經驗 獲得超4個贊
如果這是您的本地開發環境,您可以運行:
php artisan migrate:fresh
根據設計,遷移命令對文件中的更改不敏感。它使用文件名來了解它已經運行了哪些遷移以及需要運行哪些遷移。
php artisan migrate
如果您編輯了文件,第二次運行將不會產生任何效果。
要進行會改變生產數據庫的更改,您需要進行新的遷移并更改表,而不是編輯舊的遷移文件。
- 1 回答
- 0 關注
- 117 瀏覽
添加回答
舉報
0/150
提交
取消