Merge branch 'missing-features' into codex/organize-routes
This commit is contained in:
-13
@@ -23,18 +23,6 @@ return new class extends Migration
|
|||||||
$table->index(['project_id', 'board_column_id', 'position']);
|
$table->index(['project_id', 'board_column_id', 'position']);
|
||||||
$table->index(['project_id', 'slug']);
|
$table->index(['project_id', 'slug']);
|
||||||
});
|
});
|
||||||
|
|
||||||
Schema::create('ticket_status_transitions', function (Blueprint $table) {
|
|
||||||
$table->id();
|
|
||||||
$table->foreignId('from_ticket_status_id')->constrained('ticket_statuses')->cascadeOnDelete();
|
|
||||||
$table->foreignId('to_ticket_status_id')->constrained('ticket_statuses')->cascadeOnDelete();
|
|
||||||
$table->timestamps();
|
|
||||||
|
|
||||||
$table->unique(
|
|
||||||
['from_ticket_status_id', 'to_ticket_status_id'],
|
|
||||||
'ticket_status_transitions_unique',
|
|
||||||
);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -42,7 +30,6 @@ return new class extends Migration
|
|||||||
*/
|
*/
|
||||||
public function down(): void
|
public function down(): void
|
||||||
{
|
{
|
||||||
Schema::dropIfExists('ticket_status_transitions');
|
|
||||||
Schema::dropIfExists('ticket_statuses');
|
Schema::dropIfExists('ticket_statuses');
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -0,0 +1,34 @@
|
|||||||
|
<?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::create('ticket_status_transitions', function (Blueprint $table) {
|
||||||
|
$table->id();
|
||||||
|
$table->foreignId('from_ticket_status_id')->constrained('ticket_statuses')->cascadeOnDelete();
|
||||||
|
$table->foreignId('to_ticket_status_id')->constrained('ticket_statuses')->cascadeOnDelete();
|
||||||
|
$table->timestamps();
|
||||||
|
|
||||||
|
$table->unique(
|
||||||
|
['from_ticket_status_id', 'to_ticket_status_id'],
|
||||||
|
'ticket_status_transitions_unique',
|
||||||
|
);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*/
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::dropIfExists('ticket_status_transitions');
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -18,7 +18,10 @@ return new class extends Migration
|
|||||||
$table->foreignId('ticket_priority_id')->constrained()->cascadeOnDelete();
|
$table->foreignId('ticket_priority_id')->constrained()->cascadeOnDelete();
|
||||||
$table->foreignId('assignee_user_id')->nullable()->constrained('users')->nullOnDelete();
|
$table->foreignId('assignee_user_id')->nullable()->constrained('users')->nullOnDelete();
|
||||||
$table->foreignId('author_user_id')->nullable()->constrained('users')->nullOnDelete();
|
$table->foreignId('author_user_id')->nullable()->constrained('users')->nullOnDelete();
|
||||||
$table->foreignId('board_column_id')->nullable()->constrained()->nullOnDelete();
|
$table->foreignId('ticket_status_id')->nullable()->constrained()->nullOnDelete();
|
||||||
|
$table->foreignId('parent_ticket_id')->nullable()->constrained('tickets')->nullOnDelete();
|
||||||
|
$table->boolean('is_blocked')->default(false);
|
||||||
|
$table->text('blocked_comment')->nullable();
|
||||||
$table->unsignedInteger('sequence_number');
|
$table->unsignedInteger('sequence_number');
|
||||||
$table->string('ticket_key')->unique();
|
$table->string('ticket_key')->unique();
|
||||||
$table->string('title');
|
$table->string('title');
|
||||||
|
|||||||
@@ -1,32 +0,0 @@
|
|||||||
<?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('tickets', function (Blueprint $table) {
|
|
||||||
$table->foreignId('parent_ticket_id')
|
|
||||||
->nullable()
|
|
||||||
->after('board_column_id')
|
|
||||||
->constrained('tickets')
|
|
||||||
->nullOnDelete();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Reverse the migrations.
|
|
||||||
*/
|
|
||||||
public function down(): void
|
|
||||||
{
|
|
||||||
Schema::table('tickets', function (Blueprint $table) {
|
|
||||||
$table->dropConstrainedForeignId('parent_ticket_id');
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
|
||||||
@@ -1,33 +0,0 @@
|
|||||||
<?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('tickets', function (Blueprint $table) {
|
|
||||||
$table->boolean('is_blocked')
|
|
||||||
->default(false)
|
|
||||||
->after('parent_ticket_id');
|
|
||||||
$table->text('blocked_comment')
|
|
||||||
->nullable()
|
|
||||||
->after('is_blocked');
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Reverse the migrations.
|
|
||||||
*/
|
|
||||||
public function down(): void
|
|
||||||
{
|
|
||||||
Schema::table('tickets', function (Blueprint $table) {
|
|
||||||
$table->dropColumn(['blocked_comment', 'is_blocked']);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
|
||||||
-112
@@ -1,112 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
use Illuminate\Database\Migrations\Migration;
|
|
||||||
use Illuminate\Database\Schema\Blueprint;
|
|
||||||
use Illuminate\Support\Facades\DB;
|
|
||||||
use Illuminate\Support\Facades\Schema;
|
|
||||||
use Illuminate\Support\Str;
|
|
||||||
|
|
||||||
return new class extends Migration
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Run the migrations.
|
|
||||||
*/
|
|
||||||
public function up(): void
|
|
||||||
{
|
|
||||||
Schema::table('tickets', function (Blueprint $table) {
|
|
||||||
$table->foreignId('ticket_status_id')
|
|
||||||
->nullable()
|
|
||||||
->after('board_column_id')
|
|
||||||
->constrained()
|
|
||||||
->nullOnDelete();
|
|
||||||
});
|
|
||||||
|
|
||||||
$this->backfillTicketStatuses();
|
|
||||||
|
|
||||||
Schema::table('tickets', function (Blueprint $table) {
|
|
||||||
$table->dropConstrainedForeignId('board_column_id');
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Reverse the migrations.
|
|
||||||
*/
|
|
||||||
public function down(): void
|
|
||||||
{
|
|
||||||
Schema::table('tickets', function (Blueprint $table) {
|
|
||||||
$table->foreignId('board_column_id')
|
|
||||||
->nullable()
|
|
||||||
->after('author_user_id')
|
|
||||||
->constrained()
|
|
||||||
->nullOnDelete();
|
|
||||||
});
|
|
||||||
|
|
||||||
DB::table('tickets')
|
|
||||||
->leftJoin('ticket_statuses', 'tickets.ticket_status_id', '=', 'ticket_statuses.id')
|
|
||||||
->update([
|
|
||||||
'tickets.board_column_id' => DB::raw('ticket_statuses.board_column_id'),
|
|
||||||
]);
|
|
||||||
|
|
||||||
Schema::table('tickets', function (Blueprint $table) {
|
|
||||||
$table->dropConstrainedForeignId('ticket_status_id');
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
private function backfillTicketStatuses(): void
|
|
||||||
{
|
|
||||||
DB::table('projects')
|
|
||||||
->orderBy('id')
|
|
||||||
->get()
|
|
||||||
->each(function (object $project): void {
|
|
||||||
$backlogStatusId = $this->createTicketStatus(
|
|
||||||
(int) $project->id,
|
|
||||||
null,
|
|
||||||
'Backlog',
|
|
||||||
1,
|
|
||||||
);
|
|
||||||
|
|
||||||
DB::table('tickets')
|
|
||||||
->where('project_id', $project->id)
|
|
||||||
->whereNull('board_column_id')
|
|
||||||
->update(['ticket_status_id' => $backlogStatusId]);
|
|
||||||
|
|
||||||
DB::table('board_columns')
|
|
||||||
->where('project_id', $project->id)
|
|
||||||
->orderBy('position')
|
|
||||||
->get()
|
|
||||||
->each(function (object $boardColumn) use ($project): void {
|
|
||||||
$ticketStatusId = $this->createTicketStatus(
|
|
||||||
(int) $project->id,
|
|
||||||
(int) $boardColumn->id,
|
|
||||||
(string) $boardColumn->name,
|
|
||||||
1,
|
|
||||||
);
|
|
||||||
|
|
||||||
DB::table('tickets')
|
|
||||||
->where('project_id', $project->id)
|
|
||||||
->where('board_column_id', $boardColumn->id)
|
|
||||||
->update(['ticket_status_id' => $ticketStatusId]);
|
|
||||||
});
|
|
||||||
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
private function createTicketStatus(
|
|
||||||
int $projectId,
|
|
||||||
?int $boardColumnId,
|
|
||||||
string $name,
|
|
||||||
int $position,
|
|
||||||
): int {
|
|
||||||
$now = now();
|
|
||||||
|
|
||||||
return (int) DB::table('ticket_statuses')->insertGetId([
|
|
||||||
'board_column_id' => $boardColumnId,
|
|
||||||
'created_at' => $now,
|
|
||||||
'name' => $name,
|
|
||||||
'position' => $position,
|
|
||||||
'project_id' => $projectId,
|
|
||||||
'slug' => Str::slug($name),
|
|
||||||
'updated_at' => $now,
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
Reference in New Issue
Block a user