Level 102
Are you running a very old mysql version? Can you try upgrading?
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
I am trying to execute this query but giving me this error:
I will change a column from not unique to Unique.
partner_id is a foreign key.
N:B: I am working in Laravel 5.3
class ChangePartnerToPartnerFinancialInformationsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('partner_financial_informations', function (Blueprint $table) {
DB::statement('ALTER TABLE `partner_financial_informations` CHANGE `partner_id` `partner_id` INTEGER UNSIGNED UNIQUE;');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('partner_financial_informations', function (Blueprint $table) {
DB::statement('ALTER TABLE `partner_financial_informations` CHANGE `partner_id` `partner_id` INTEGER UNSIGNED NOT NULL;');
});
}
}
Full Error:
[Illuminate\Database\QueryException]
SQLSTATE[70100]: \Unknown error>>: 1317 Query execution was interrupted (SQL: ALTER TABLE `partner_financial_informations` CHANGE `partner_id` `partner_id` INTEGER UNSIGNED UNIQUE;)
[PDOException]
SQLSTATE[70100]: \Unknown error>>: 1317 Query execution was interrupted
You don't need to wrap a statement within a Schema.
This
Schema::table('partner_financial_informations', function (Blueprint $table) {
DB::statement('ALTER TABLE `partner_financial_informations` CHANGE `partner_id` `partner_id` INTEGER UNSIGNED UNIQUE;');
});
can be just
DB::statement('ALTER TABLE `partner_financial_informations` CHANGE `partner_id` `partner_id` INTEGER UNSIGNED UNIQUE;');
but you can consider using Laravel only: https://laravel.com/docs/9.x/migrations#prerequisites
this maybe:
Schema::table('partner_financial_informations', function (Blueprint $table) {
$table->foreignId('partner_id')->unique()->change();
});
Please or to participate in this conversation.