Neustrukturierung Customer / Lead / Booking Phase 2

This commit is contained in:
Kevin Adametz 2026-05-28 17:10:37 +02:00
parent 313f0dbf4e
commit 6df9c401af
69 changed files with 3809 additions and 374 deletions

View file

@ -8,7 +8,7 @@ use Illuminate\Database\Migrations\Migration;
* Migration auto-generated by Sequel Pro Laravel Export (1.4.1)
* @see https://github.com/cviebrock/sequel-pro-laravel-export
*/
class CreateBookingVoucherTable extends Migration
class CreateBookingVoucherAgencyTable extends Migration
{
/**
* Run the migrations.

View file

@ -1,47 +0,0 @@
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
/**
* Migration auto-generated by Sequel Pro Laravel Export (1.4.1)
* @see https://github.com/cviebrock/sequel-pro-laravel-export
*/
class CreateBookingVoucherTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('booking_voucher', function (Blueprint $table) {
$table->bigIncrements('id');
$table->bigInteger('booking_id');
$table->binary('binary_data');
$table->dateTime('created_at');
$table->dateTime('updated_at');
$table->index('booking_id', 'booking_voucher_booking_id_idx');
$table->foreign('booking_id', 'booking_voucher_booking_id_booking_id')->references('id')->on('booking')->onDelete('CASCADE
')->onUpdate('RESTRICT');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('booking_voucher');
}
}

View file

@ -28,19 +28,14 @@ return new class extends Migration
$t->id();
$t->string('offer_number', 32)->unique();
$t->foreignId('contact_id')
->constrained('contacts')
->restrictOnDelete();
$t->foreignId('inquiry_id')
->nullable()
->constrained('inquiries')
->nullOnDelete();
$t->foreignId('booking_id')
->nullable()
->constrained('booking')
->nullOnDelete();
// FK-Typen MÜSSEN exakt zur Referenz passen.
// Die Legacy-Tabellen contacts/inquiries/booking sind aus dem
// alten Sequel-Pro-Export mit `bigint` (SIGNED) angelegt; die
// users-Tabelle nutzt `int unsigned`. Daher hier explizit
// typisieren statt foreignId() (das würde bigint UNSIGNED erzeugen).
$t->bigInteger('contact_id');
$t->bigInteger('inquiry_id')->nullable();
$t->bigInteger('booking_id')->nullable();
$t->enum('status', [
'draft',
@ -54,11 +49,17 @@ return new class extends Migration
// FK wird in 2026_04_17_100007 nachträglich gesetzt
$t->unsignedBigInteger('current_version_id')->nullable();
$t->foreignId('created_by')->constrained('users');
// users.id ist int unsigned (Legacy)
$t->unsignedInteger('created_by');
$t->timestamps();
$t->softDeletes();
$t->foreign('contact_id')->references('id')->on('contacts')->restrictOnDelete();
$t->foreign('inquiry_id')->references('id')->on('inquiries')->nullOnDelete();
$t->foreign('booking_id')->references('id')->on('booking')->nullOnDelete();
$t->foreign('created_by')->references('id')->on('users');
$t->index(['status', 'contact_id']);
$t->index('inquiry_id');
});

View file

@ -65,10 +65,13 @@ return new class extends Migration
// die mit dieser Version (als Anhang) verknüpft sind
$t->json('template_document_ids')->nullable();
$t->foreignId('created_by')->constrained('users');
// users.id ist int unsigned (Legacy) → siehe Migration 100001
$t->unsignedInteger('created_by');
$t->timestamps();
$t->foreign('created_by')->references('id')->on('users');
$t->unique(['offer_id', 'version_no']);
$t->index(['offer_id', 'status']);
});

View file

@ -26,10 +26,8 @@ return new class extends Migration
// `branch` existiert schon im CRM — Vorlagen können so pro
// Filiale gepflegt werden. Eine spätere Erweiterung auf
// `organization_id` (Modul 5) erfolgt additiv.
$t->foreignId('branch_id')
->nullable()
->constrained('branch')
->nullOnDelete();
// FK-Typen: branch.id ist bigint signed, users.id int unsigned.
$t->bigInteger('branch_id')->nullable();
$t->string('name');
$t->text('description')->nullable();
@ -43,11 +41,14 @@ return new class extends Migration
$t->json('default_items')->nullable();
$t->boolean('is_active')->default(true);
$t->foreignId('created_by')->constrained('users');
$t->unsignedInteger('created_by');
$t->timestamps();
$t->softDeletes();
$t->foreign('branch_id')->references('id')->on('branch')->nullOnDelete();
$t->foreign('created_by')->references('id')->on('users');
$t->index(['branch_id', 'is_active']);
});