remove disable FK check on migrate

This commit is contained in:
Jérémy Munsch 2023-09-04 17:20:53 +02:00
parent 5ea039ccfe
commit 8622dfd2bd
No known key found for this signature in database
GPG key ID: 18361AF3BFEC0FEC

View file

@ -36,7 +36,7 @@ class UpdateDocumentTable extends Migration
DB::statement('ALTER TABLE `documents` CHANGE `updated_at` `updated_at` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP');
self::updateData();
Schema::disableForeignKeyConstraints();
// * Set all orphans documents
Schema::table('documents', function (Blueprint $table) {
$table->bigInteger('parent')->unsigned()->change();
$table->renameColumn('directory', 'directory_id');
@ -48,7 +48,6 @@ class UpdateDocumentTable extends Migration
$table->renameColumn('published', 'status');
$table->dateTime('created_at')->default('CURRENT_TIMESTAMP')->nullable()->change();
});
Schema::enableForeignKeyConstraints();
foreach ($this->documentsNew as $key => $documentNew) {
$documentNew->document_id =
($this->documentsOld[$key]->parent !== null) ? intval($this->documentsOld[$key]->parent) : null;