ldc-com-app-bo/database/migrations/2025_05_26_091952_alter_relations.php
2025-05-28 17:25:44 +02:00

99 lines
3.4 KiB
PHP

<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up(): void
{
Schema::table('contacts', function (Blueprint $table) {
$table->dropForeign(['user_id']);
$table->foreign('app_user_id')
->references('id')->on('app_users')
->onDelete('cascade');
});
Schema::table('directorables', function (Blueprint $table) {
$table->dropForeign(['directory_id']);
$table->foreign('directory_id')
->references('id')->on('directories')
->onDelete('cascade');
});
Schema::table('directories', function (Blueprint $table) {
$table->dropForeign('directories_parent_foreign');
$table->foreign('directory_id')
->references('id')
->on('directories')
->onDelete('cascade');
});
Schema::table('documents', function (Blueprint $table) {
$table->dropForeign('documents_directory_foreign');
$table->foreign('directory_id')
->references('id')
->on('directories')
->onDelete('cascade');
$table->dropForeign('documents_document_id_foreign');
$table->foreign('document_id')
->references('id')
->on('documents')
->onDelete('cascade');
$table->dropColumn('parent');
});
Schema::table('taggables', function (Blueprint $table) {
$table->dropForeign(['tag_id']);
$table->foreign('tag_id')
->references('id')->on('tags')
->onDelete('cascade');
$table->dropForeign(['taggable_id']);
$table->foreign('taggable_id')
->references('id')->on('documents')
->onDelete('cascade');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down(): void
{
Schema::table('contacts', function (Blueprint $table) {
$table->dropForeign(['app_user_id']);
$table->foreign('app_user_id')
->references('id')->on('app_users');
});
Schema::table('directorables', function (Blueprint $table) {
$table->dropForeign(['directory_id']);
$table->foreign('directory_id')
->references('id')->on('directories');
});
Schema::table('directories', function (Blueprint $table) {
$table->dropForeign(['directory_id']);
$table->foreign('directory_id')
->references('id')
->on('directories');
});
Schema::table('documents', function (Blueprint $table) {
$table->dropForeign(['directory_id']);
$table->foreign('directory_id')
->references('id')
->on('directories');
$table->dropForeign(['document_id']);
$table->foreign('document_id')
->references('id')
->on('documents');
});
Schema::table('taggables', function (Blueprint $table) {
$table->dropForeign(['tag_id']);
$table->foreign('tag_id')
->references('id')->on('tags');
});
}
};