refactor: replace custom CRM with Monica fork
Some checks failed
Build & Push Monica Image to Gitea Registry / build-and-push (push) Failing after 9s

This commit is contained in:
Kroonk
2026-05-22 16:19:55 +02:00
parent 38cc4c09ca
commit a213a1dba0
2215 changed files with 242567 additions and 6015 deletions

View File

@@ -0,0 +1,43 @@
<?php
use Illuminate\Support\Facades\DB;
use App\Models\Relationship\Relationship;
use Illuminate\Database\Migrations\Migration;
class FixContactsData extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
// because of older migrations, we have some contacts in the relationships table with an ID, but
// the actual object doesn't exist. we need to find those contacts and delete the entries in the
// relationships table.
$relationships = Relationship::select('id', 'contact_is', 'of_contact')->get();
$lineContactIsToDelete = collect([]);
$lineOfContactToDelete = collect([]);
foreach ($relationships as $relationship) {
$contact = DB::table('contacts')->where('id', $relationship->contact_is)->first();
if (! $contact) {
$lineContactIsToDelete->push($relationship);
}
$contact = DB::table('contacts')->where('id', $relationship->of_contact)->first();
if (! $contact) {
$lineOfContactToDelete->push($relationship);
}
}
foreach ($lineContactIsToDelete as $relationship) {
DB::table('relationships')->where('id', $relationship->id)->delete();
}
foreach ($lineOfContactToDelete as $relationship) {
DB::table('relationships')->where('id', $relationship->id)->delete();
}
}
}