Model ticket link counterparts explicitly
linter / quality (pull_request) Successful in 3m5s
tests / ci (8.4) (pull_request) Failing after 1m41s

This commit is contained in:
2026-05-23 10:29:22 +00:00
parent d60c33fa7c
commit 486994e441
22 changed files with 312 additions and 66 deletions
+3 -5
View File
@@ -60,15 +60,13 @@ class TicketLinkFactory extends Factory
->first()
?? TicketLinkType::factory()->for($sourceTicket->project)->create([
'label' => 'Relates to',
'counterpart_label' => 'Relates to',
'position' => 1,
])
: TicketLinkType::query()->findOrFail($ticketLink->ticket_link_type_id);
$sortedIds = [$sourceTicket->id, $targetTicket->id];
sort($sortedIds);
$ticketLink->source_ticket_id = $sortedIds[0];
$ticketLink->target_ticket_id = $sortedIds[1];
$ticketLink->source_ticket_id = $sourceTicket->id;
$ticketLink->target_ticket_id = $targetTicket->id;
$ticketLink->ticket_link_type_id = $ticketLinkType->id;
});
}
+4 -1
View File
@@ -18,8 +18,11 @@ class TicketLinkTypeFactory extends Factory
*/
public function definition(): array
{
$label = fake()->unique()->words(2, true);
return [
'label' => fake()->unique()->words(2, true),
'label' => $label,
'counterpart_label' => $label,
'position' => 1,
'project_id' => Project::factory(),
];
@@ -0,0 +1,28 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::table('ticket_link_types', function (Blueprint $table) {
$table->string('counterpart_label')->nullable()->after('label');
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('ticket_link_types', function (Blueprint $table) {
$table->dropColumn('counterpart_label');
});
}
};
+2 -2
View File
@@ -20,8 +20,8 @@ class TicketLinkTypeSeeder extends Seeder
TicketLinkType::factory()
->count(2)
->sequence(
['label' => 'Relates to', 'position' => 1],
['label' => 'Blocks', 'position' => 2],
['label' => 'Relates to', 'counterpart_label' => 'Relates to', 'position' => 1],
['label' => 'Blocks', 'counterpart_label' => 'Blocked by', 'position' => 2],
)
->for($project)
->create();