Add project repository connection settings
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use App\Actions\Git\GitProviderKey;
|
||||
use App\Models\Project;
|
||||
use App\Models\RepositoryConnection;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
/**
|
||||
* @extends Factory<RepositoryConnection>
|
||||
*/
|
||||
class RepositoryConnectionFactory extends Factory
|
||||
{
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function definition(): array
|
||||
{
|
||||
return [
|
||||
'base_url' => 'https://git.'.fake()->domainName(),
|
||||
'owner_name' => fake()->userName(),
|
||||
'project_id' => Project::factory(),
|
||||
'provider' => GitProviderKey::Gitea,
|
||||
'provider_repository_id' => (string) fake()->numberBetween(1, 999_999),
|
||||
'repository_full_name' => fake()->userName().'/'.fake()->slug(),
|
||||
'repository_name' => fake()->slug(),
|
||||
'repository_url' => 'https://git.'.fake()->domainName().'/'.fake()->userName().'/'.fake()->slug(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
<?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('repository_connections', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('project_id')->constrained()->cascadeOnDelete();
|
||||
$table->string('provider');
|
||||
$table->string('base_url');
|
||||
$table->string('provider_repository_id');
|
||||
$table->string('owner_name');
|
||||
$table->string('repository_name');
|
||||
$table->string('repository_full_name');
|
||||
$table->string('repository_url');
|
||||
$table->timestamps();
|
||||
|
||||
$table->unique([
|
||||
'project_id',
|
||||
'provider',
|
||||
'base_url',
|
||||
'provider_repository_id',
|
||||
]);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('repository_connections');
|
||||
}
|
||||
};
|
||||
@@ -16,6 +16,7 @@ class DatabaseSeeder extends Seeder
|
||||
UserSeeder::class,
|
||||
UserGitConnectionSeeder::class,
|
||||
ProjectSeeder::class,
|
||||
RepositoryConnectionSeeder::class,
|
||||
BoardColumnSeeder::class,
|
||||
ProjectTicketMetadataSeeder::class,
|
||||
TicketSeeder::class,
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use App\Actions\Git\GitProviderKey;
|
||||
use App\Models\Project;
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
class RepositoryConnectionSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*/
|
||||
public function run(): void
|
||||
{
|
||||
$project = Project::query()->where('key', 'CORE')->first()
|
||||
?? Project::query()->orderBy('id')->first();
|
||||
|
||||
if ($project === null) {
|
||||
return;
|
||||
}
|
||||
|
||||
$project->repositoryConnections()->firstOrCreate(
|
||||
[
|
||||
'provider' => GitProviderKey::Gitea,
|
||||
'base_url' => 'https://git.example.test',
|
||||
'provider_repository_id' => '501',
|
||||
],
|
||||
[
|
||||
'owner_name' => 'core-team',
|
||||
'repository_name' => 'kanbangit',
|
||||
'repository_full_name' => 'core-team/kanbangit',
|
||||
'repository_url' => 'https://git.example.test/core-team/kanbangit',
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user