table('production_pauses'); // 1. rimuovo la FK che blocca la modifica della colonna $table->dropForeignKey('reason_id')->update(); // 2. rendo la colonna nullable, mantenendo il tipo reale (tinyint unsigned) $table->changeColumn('reason_id', 'integer', [ 'limit' => \Phinx\Db\Adapter\MysqlAdapter::INT_TINY, 'signed' => false, 'null' => true, ])->update(); // 3. ricreo la FK $table->addForeignKey('reason_id', 'pause_reasons', 'id', [ 'delete' => 'SET_NULL', 'update' => 'NO_ACTION', ])->update(); } public function down(): void { $table = $this->table('production_pauses'); $table->dropForeignKey('reason_id')->update(); $table->changeColumn('reason_id', 'integer', [ 'limit' => \Phinx\Db\Adapter\MysqlAdapter::INT_TINY, 'signed' => false, 'null' => false, ])->update(); $table->addForeignKey('reason_id', 'pause_reasons', 'id', [ 'delete' => 'NO_ACTION', 'update' => 'NO_ACTION', ])->update(); } }