From 77a8d37a586c683c3542bdbbbb0830a96b8636b1 Mon Sep 17 00:00:00 2001 From: Eduard Kozachok Date: Fri, 18 Apr 2025 00:54:27 +0300 Subject: [PATCH] Correct the column rename in add_title_fields_to_contacts_table.php.stub I faced an issue with `$table->rename('title_before', 'title');` - it renames 'contacts` table and migration itself obviously failed with the following error: ``` SQLSTATE[42S02]: Base table or view not found: 1146 Table 'db.contacts' doesn't exist (Connection: mariadb, SQL: alter table `contacts` rename column `title` to `title_before`) ``` --- .../migrations/add_title_fields_to_contacts_table.php.stub | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/database/migrations/add_title_fields_to_contacts_table.php.stub b/database/migrations/add_title_fields_to_contacts_table.php.stub index adfa2de..6168c21 100644 --- a/database/migrations/add_title_fields_to_contacts_table.php.stub +++ b/database/migrations/add_title_fields_to_contacts_table.php.stub @@ -16,7 +16,7 @@ class AddTitleFieldsToContactsTable extends Migration public function up(): void { Schema::table($this->table, function (Blueprint $table) { - $table->rename('title', 'title_before'); + $table->renameColumn('title', 'title_before'); $table->string('title_after')->nullable()->after('title_before'); }); } @@ -24,7 +24,7 @@ class AddTitleFieldsToContactsTable extends Migration public function down(): void { Schema::table($this->table, function (Blueprint $table) { - $table->rename('title_before', 'title'); + $table->renameColumn('title_before', 'title'); $table->dropColumn('title_after'); }); }