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,51 @@
<?php
use App\Models\Account\Account;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class AddDefaultGender extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('accounts', function (Blueprint $table) {
$table->unsignedInteger('default_gender_id')->after('default_time_reminder_is_sent')->nullable();
$table->foreign('default_gender_id')->references('id')->on('genders')->onDelete('set null');
});
DB::table('genders')
->groupBy('account_id')
->select(DB::raw('min(id) as id, account_id'))
->orderBy('id')
->chunk(200, function ($genders) {
foreach ($genders as $gender) {
/** @var Account */
$account = Account::find($gender->account_id);
if ($account) {
$account->default_gender_id = $gender->id;
$account->save();
}
}
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('accounts', function (Blueprint $table) {
$table->dropForeign(['default_gender_id']);
$table->dropColumn('default_gender_id');
});
}
}