Proje dosyaları eklendi
This commit is contained in:
@@ -0,0 +1 @@
|
||||
*.sqlite*
|
||||
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use App\Enums\EarnMemberStatus;
|
||||
use App\Models\EarnMember;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
|
||||
/** @extends Factory<EarnMember> */
|
||||
class EarnMemberFactory extends Factory
|
||||
{
|
||||
protected $model = EarnMember::class;
|
||||
|
||||
public function definition(): array
|
||||
{
|
||||
return [
|
||||
'name' => fake()->name(),
|
||||
'email' => fake()->unique()->safeEmail(),
|
||||
'password' => Hash::make('password'),
|
||||
'status' => EarnMemberStatus::Active,
|
||||
'email_verified_at' => now(),
|
||||
];
|
||||
}
|
||||
|
||||
public function pending(): static
|
||||
{
|
||||
return $this->state(['status' => EarnMemberStatus::Pending]);
|
||||
}
|
||||
|
||||
public function unverified(): static
|
||||
{
|
||||
return $this->state(['email_verified_at' => null]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
<?php
|
||||
namespace Database\Factories; use App\Models\Project; use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
class KeywordFactory extends Factory { public function definition():array{$p=fake()->unique()->words(3,true);return ['project_id'=>Project::factory(),'phrase'=>$p,'normalized_phrase'=>mb_strtolower($p),'search_engine'=>'google','country_code'=>'TR','language_code'=>'tr','device'=>'desktop'];}}
|
||||
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use App\Models\User;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
|
||||
class ProjectFactory extends Factory
|
||||
{
|
||||
public function definition(): array
|
||||
{
|
||||
$domain = fake()->unique()->domainName();
|
||||
return ['user_id' => User::factory(), 'name' => fake()->company(), 'domain' => $domain, 'url' => 'https://'.$domain];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
<?php
|
||||
namespace Database\Factories; use App\Models\Keyword; use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
class SerpCheckFactory extends Factory {public function definition():array{return ['phrase'=>'Test keyword','keyword_id'=>Keyword::factory(),'status'=>'completed','checked_at'=>now(),'search_engine'=>'google','country_code'=>'TR','language_code'=>'tr','device'=>'desktop','result_count'=>0];}}
|
||||
@@ -0,0 +1,3 @@
|
||||
<?php
|
||||
namespace Database\Factories; use App\Models\SerpCheck; use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
class SerpResultFactory extends Factory {public function definition():array{return ['serp_check_id'=>SerpCheck::factory(),'position'=>fake()->unique()->numberBetween(1,100),'result_type'=>'organic','title'=>fake()->sentence(),'url'=>fake()->url(),'display_url'=>fake()->domainName(),'snippet'=>fake()->sentence(),'is_project_domain'=>false];}}
|
||||
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Factories;
|
||||
|
||||
use App\Enums\UserStatus;
|
||||
use App\Models\User;
|
||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
/**
|
||||
* @extends Factory<User>
|
||||
*/
|
||||
class UserFactory extends Factory
|
||||
{
|
||||
/**
|
||||
* The current password being used by the factory.
|
||||
*/
|
||||
protected static ?string $password;
|
||||
|
||||
/**
|
||||
* Define the model's default state.
|
||||
*
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function definition(): array
|
||||
{
|
||||
return [
|
||||
'name' => fake()->name(),
|
||||
'email' => fake()->unique()->safeEmail(),
|
||||
'email_verified_at' => now(),
|
||||
'password' => static::$password ??= Hash::make('password'),
|
||||
'status' => UserStatus::Active,
|
||||
'remember_token' => Str::random(10),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicate that the model's email address should be unverified.
|
||||
*/
|
||||
public function unverified(): static
|
||||
{
|
||||
return $this->state(fn (array $attributes) => [
|
||||
'email_verified_at' => null,
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
<?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('users', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('name');
|
||||
$table->string('email')->unique();
|
||||
$table->timestamp('email_verified_at')->nullable();
|
||||
$table->string('password');
|
||||
$table->rememberToken();
|
||||
$table->timestamps();
|
||||
});
|
||||
|
||||
Schema::create('password_reset_tokens', function (Blueprint $table) {
|
||||
$table->string('email')->primary();
|
||||
$table->string('token');
|
||||
$table->timestamp('created_at')->nullable();
|
||||
});
|
||||
|
||||
Schema::create('sessions', function (Blueprint $table) {
|
||||
$table->string('id')->primary();
|
||||
$table->foreignId('user_id')->nullable()->index();
|
||||
$table->string('ip_address', 45)->nullable();
|
||||
$table->text('user_agent')->nullable();
|
||||
$table->longText('payload');
|
||||
$table->integer('last_activity')->index();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('users');
|
||||
Schema::dropIfExists('password_reset_tokens');
|
||||
Schema::dropIfExists('sessions');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,35 @@
|
||||
<?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('cache', function (Blueprint $table) {
|
||||
$table->string('key')->primary();
|
||||
$table->mediumText('value');
|
||||
$table->bigInteger('expiration')->index();
|
||||
});
|
||||
|
||||
Schema::create('cache_locks', function (Blueprint $table) {
|
||||
$table->string('key')->primary();
|
||||
$table->string('owner');
|
||||
$table->bigInteger('expiration')->index();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('cache');
|
||||
Schema::dropIfExists('cache_locks');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,57 @@
|
||||
<?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('jobs', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('queue')->index();
|
||||
$table->longText('payload');
|
||||
$table->unsignedTinyInteger('attempts');
|
||||
$table->unsignedInteger('reserved_at')->nullable();
|
||||
$table->unsignedInteger('available_at');
|
||||
$table->unsignedInteger('created_at');
|
||||
});
|
||||
|
||||
Schema::create('job_batches', function (Blueprint $table) {
|
||||
$table->string('id')->primary();
|
||||
$table->string('name');
|
||||
$table->integer('total_jobs');
|
||||
$table->integer('pending_jobs');
|
||||
$table->integer('failed_jobs');
|
||||
$table->longText('failed_job_ids');
|
||||
$table->mediumText('options')->nullable();
|
||||
$table->integer('cancelled_at')->nullable();
|
||||
$table->integer('created_at');
|
||||
$table->integer('finished_at')->nullable();
|
||||
});
|
||||
|
||||
Schema::create('failed_jobs', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('uuid')->unique();
|
||||
$table->text('connection');
|
||||
$table->text('queue');
|
||||
$table->longText('payload');
|
||||
$table->longText('exception');
|
||||
$table->timestamp('failed_at')->useCurrent();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('jobs');
|
||||
Schema::dropIfExists('job_batches');
|
||||
Schema::dropIfExists('failed_jobs');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,33 @@
|
||||
<?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('personal_access_tokens', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->morphs('tokenable');
|
||||
$table->text('name');
|
||||
$table->string('token', 64)->unique();
|
||||
$table->text('abilities')->nullable();
|
||||
$table->timestamp('last_used_at')->nullable();
|
||||
$table->timestamp('expires_at')->nullable()->index();
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('personal_access_tokens');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration {
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('users', function (Blueprint $table) {
|
||||
$table->string('status', 32)->default('active')->index()->after('password');
|
||||
$table->timestamp('last_login_at')->nullable()->after('status');
|
||||
$table->string('last_login_ip', 45)->nullable()->after('last_login_at');
|
||||
});
|
||||
}
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('users', function (Blueprint $table) {
|
||||
$table->dropIndex(['status']);
|
||||
$table->dropColumn(['status', 'last_login_at', 'last_login_ip']);
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,61 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration {
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('roles', function (Blueprint $table) {
|
||||
$table->id(); $table->string('name', 64)->unique(); $table->string('label'); $table->timestamps();
|
||||
});
|
||||
Schema::create('permissions', function (Blueprint $table) {
|
||||
$table->id(); $table->string('name', 96)->unique(); $table->string('label'); $table->timestamps();
|
||||
});
|
||||
Schema::create('role_user', function (Blueprint $table) {
|
||||
$table->foreignId('role_id')->constrained()->cascadeOnDelete();
|
||||
$table->foreignId('user_id')->constrained()->cascadeOnDelete();
|
||||
$table->timestamps(); $table->primary(['role_id', 'user_id']);
|
||||
});
|
||||
Schema::create('permission_role', function (Blueprint $table) {
|
||||
$table->foreignId('permission_id')->constrained()->cascadeOnDelete();
|
||||
$table->foreignId('role_id')->constrained()->cascadeOnDelete();
|
||||
$table->timestamps(); $table->primary(['permission_id', 'role_id']);
|
||||
});
|
||||
|
||||
$now = now();
|
||||
DB::table('roles')->insert([
|
||||
['name' => 'super_admin', 'label' => 'Süper Admin', 'created_at' => $now, 'updated_at' => $now],
|
||||
['name' => 'admin', 'label' => 'Admin', 'created_at' => $now, 'updated_at' => $now],
|
||||
['name' => 'support', 'label' => 'Destek', 'created_at' => $now, 'updated_at' => $now],
|
||||
['name' => 'customer', 'label' => 'Müşteri', 'created_at' => $now, 'updated_at' => $now],
|
||||
]);
|
||||
DB::table('permissions')->insert([
|
||||
['name' => 'admin.access', 'label' => 'Admin paneline erişim', 'created_at' => $now, 'updated_at' => $now],
|
||||
['name' => 'users.view', 'label' => 'Kullanıcıları görüntüleme', 'created_at' => $now, 'updated_at' => $now],
|
||||
['name' => 'users.manage', 'label' => 'Kullanıcıları yönetme', 'created_at' => $now, 'updated_at' => $now],
|
||||
['name' => 'roles.assign', 'label' => 'Rol atama', 'created_at' => $now, 'updated_at' => $now],
|
||||
['name' => 'system.manage', 'label' => 'Sistem yönetimi', 'created_at' => $now, 'updated_at' => $now],
|
||||
]);
|
||||
$roles = DB::table('roles')->pluck('id', 'name');
|
||||
$permissions = DB::table('permissions')->pluck('id', 'name');
|
||||
$grants = [
|
||||
'super_admin' => $permissions->keys()->all(),
|
||||
'admin' => ['admin.access', 'users.view', 'users.manage', 'roles.assign'],
|
||||
'support' => ['admin.access', 'users.view'],
|
||||
];
|
||||
foreach ($grants as $role => $names) foreach ($names as $name) {
|
||||
DB::table('permission_role')->insert([
|
||||
'role_id' => $roles[$role], 'permission_id' => $permissions[$name],
|
||||
'created_at' => $now, 'updated_at' => $now,
|
||||
]);
|
||||
}
|
||||
}
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('permission_role'); Schema::dropIfExists('role_user');
|
||||
Schema::dropIfExists('permissions'); Schema::dropIfExists('roles');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration {
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('projects', function (Blueprint $table): void {
|
||||
$table->id();
|
||||
$table->ulid('ulid')->unique();
|
||||
$table->foreignId('user_id')->constrained()->restrictOnDelete();
|
||||
$table->string('name', 150);
|
||||
$table->string('domain', 253);
|
||||
$table->string('url', 2048);
|
||||
$table->string('status', 20)->default('active')->index();
|
||||
$table->timestamp('archived_at')->nullable()->index();
|
||||
$table->timestamps();
|
||||
$table->unique(['user_id', 'domain']);
|
||||
});
|
||||
}
|
||||
public function down(): void { Schema::dropIfExists('projects'); }
|
||||
};
|
||||
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
return new class extends Migration {
|
||||
public function up(): void
|
||||
{
|
||||
$now = now();
|
||||
foreach (['projects.view' => 'Projeleri görüntüleme', 'projects.manage' => 'Projeleri yönetme'] as $name => $label) {
|
||||
DB::table('permissions')->insertOrIgnore(['name' => $name, 'label' => $label, 'created_at' => $now, 'updated_at' => $now]);
|
||||
}
|
||||
$roles = DB::table('roles')->whereIn('name', ['super_admin', 'admin', 'support'])->pluck('id', 'name');
|
||||
$permissions = DB::table('permissions')->whereIn('name', ['projects.view', 'projects.manage'])->pluck('id', 'name');
|
||||
foreach (['super_admin', 'admin'] as $role) {
|
||||
if (! isset($roles[$role])) continue;
|
||||
foreach ($permissions as $permissionId) {
|
||||
DB::table('permission_role')->insertOrIgnore(['role_id' => $roles[$role], 'permission_id' => $permissionId, 'created_at' => $now, 'updated_at' => $now]);
|
||||
}
|
||||
}
|
||||
if (isset($roles['support'], $permissions['projects.view'])) {
|
||||
DB::table('permission_role')->insertOrIgnore(['role_id' => $roles['support'], 'permission_id' => $permissions['projects.view'], 'created_at' => $now, 'updated_at' => $now]);
|
||||
}
|
||||
}
|
||||
public function down(): void
|
||||
{
|
||||
$ids = DB::table('permissions')->whereIn('name', ['projects.view', 'projects.manage'])->pluck('id');
|
||||
DB::table('permission_role')->whereIn('permission_id', $ids)->delete();
|
||||
DB::table('permissions')->whereIn('id', $ids)->delete();
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,3 @@
|
||||
<?php
|
||||
use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema;
|
||||
return new class extends Migration { public function up():void{Schema::create('keywords',function(Blueprint $t){$t->id();$t->ulid('ulid')->unique();$t->foreignId('project_id')->constrained()->restrictOnDelete();$t->string('phrase',190);$t->string('normalized_phrase',190);$t->string('search_engine',16);$t->char('country_code',2);$t->string('language_code',8);$t->string('device',16);$t->string('status',20)->default('active')->index();$t->timestamp('archived_at')->nullable()->index();$t->timestamps();$t->index(['search_engine','country_code','language_code','device'],'keywords_target_index');$t->unique(['project_id','normalized_phrase','search_engine','country_code','language_code','device'],'keywords_target_unique');});} public function down():void{Schema::dropIfExists('keywords');}};
|
||||
@@ -0,0 +1,6 @@
|
||||
<?php
|
||||
use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema;
|
||||
return new class extends Migration { public function up():void{
|
||||
Schema::create('serp_checks',function(Blueprint $t){$t->id();$t->ulid('ulid')->unique();$t->foreignId('keyword_id')->constrained()->restrictOnDelete();$t->string('status',20)->default('pending')->index();$t->timestamp('checked_at')->nullable();$t->string('search_engine',16);$t->char('country_code',2);$t->string('language_code',8);$t->string('device',16);$t->string('provider',64)->nullable();$t->unsignedInteger('result_count')->default(0);$t->string('error_code',64)->nullable();$t->text('error_message')->nullable();$t->timestamps();$t->index(['keyword_id','checked_at']);});
|
||||
Schema::create('serp_results',function(Blueprint $t){$t->id();$t->foreignId('serp_check_id')->constrained()->restrictOnDelete();$t->unsignedInteger('position');$t->string('result_type',32)->default('organic');$t->string('title',500)->nullable();$t->string('url',2048);$t->string('display_url',500)->nullable();$t->text('snippet')->nullable();$t->boolean('is_project_domain')->default(false);$t->timestamps();$t->unique(['serp_check_id','position']);});
|
||||
} public function down():void{Schema::dropIfExists('serp_results');Schema::dropIfExists('serp_checks');}};
|
||||
@@ -0,0 +1,3 @@
|
||||
<?php
|
||||
use Illuminate\Database\Migrations\Migration; use Illuminate\Support\Facades\DB;
|
||||
return new class extends Migration { public function up():void{$n=now();foreach(['keywords.view'=>'Anahtar kelimeleri görüntüleme','keywords.manage'=>'Anahtar kelimeleri yönetme'] as $name=>$label)DB::table('permissions')->insertOrIgnore(compact('name','label')+['created_at'=>$n,'updated_at'=>$n]);$r=DB::table('roles')->pluck('id','name');$p=DB::table('permissions')->whereIn('name',['keywords.view','keywords.manage'])->pluck('id','name');foreach(['super_admin','admin'] as $role)if(isset($r[$role]))foreach($p as $id)DB::table('permission_role')->insertOrIgnore(['role_id'=>$r[$role],'permission_id'=>$id,'created_at'=>$n,'updated_at'=>$n]);if(isset($r['support'],$p['keywords.view']))DB::table('permission_role')->insertOrIgnore(['role_id'=>$r['support'],'permission_id'=>$p['keywords.view'],'created_at'=>$n,'updated_at'=>$n]);} public function down():void{$ids=DB::table('permissions')->whereIn('name',['keywords.view','keywords.manage'])->pluck('id');DB::table('permission_role')->whereIn('permission_id',$ids)->delete();DB::table('permissions')->whereIn('id',$ids)->delete();}};
|
||||
@@ -0,0 +1,6 @@
|
||||
<?php
|
||||
use Illuminate\Database\Migrations\Migration;use Illuminate\Database\Schema\Blueprint;use Illuminate\Support\Facades\Schema;
|
||||
return new class extends Migration {public function up():void{
|
||||
Schema::table('keywords',function(Blueprint $t){$t->boolean('tracking_enabled')->default(false)->after('device');$t->string('check_frequency',16)->default('daily')->after('tracking_enabled');$t->timestamp('next_check_at')->nullable()->after('check_frequency');$t->timestamp('last_queued_at')->nullable()->after('next_check_at');$t->index(['tracking_enabled','next_check_at']);});
|
||||
Schema::table('serp_checks',function(Blueprint $t){$t->string('phrase',190)->default('')->after('keyword_id');$t->string('active_slot',16)->nullable()->after('status');$t->timestamp('started_at')->nullable();$t->timestamp('completed_at')->nullable();$t->timestamp('failed_at')->nullable();$t->string('provider_reference',191)->nullable();$t->unsignedInteger('duration_ms')->nullable();$t->unique(['keyword_id','active_slot'],'serp_checks_keyword_active_unique');$t->index(['keyword_id','status']);});
|
||||
}public function down():void{Schema::table('serp_checks',function(Blueprint $t){$t->dropUnique('serp_checks_keyword_active_unique');$t->dropIndex(['keyword_id','status']);$t->dropColumn(['phrase','active_slot','started_at','completed_at','failed_at','provider_reference','duration_ms']);});Schema::table('keywords',function(Blueprint $t){$t->dropIndex(['tracking_enabled','next_check_at']);$t->dropColumn(['tracking_enabled','check_frequency','next_check_at','last_queued_at']);});}};
|
||||
@@ -0,0 +1,3 @@
|
||||
<?php
|
||||
use Illuminate\Database\Migrations\Migration;use Illuminate\Support\Facades\DB;
|
||||
return new class extends Migration {public function up():void{$n=now();foreach(['serp_checks.view'=>'SERP kontrollerini görüntüleme','serp_checks.manage'=>'SERP kontrollerini yönetme'] as $name=>$label)DB::table('permissions')->insertOrIgnore(compact('name','label')+['created_at'=>$n,'updated_at'=>$n]);$r=DB::table('roles')->pluck('id','name');$p=DB::table('permissions')->whereIn('name',['serp_checks.view','serp_checks.manage'])->pluck('id','name');foreach(['super_admin','admin'] as $role)if(isset($r[$role]))foreach($p as $id)DB::table('permission_role')->insertOrIgnore(['role_id'=>$r[$role],'permission_id'=>$id,'created_at'=>$n,'updated_at'=>$n]);if(isset($r['support'],$p['serp_checks.view']))DB::table('permission_role')->insertOrIgnore(['role_id'=>$r['support'],'permission_id'=>$p['serp_checks.view'],'created_at'=>$n,'updated_at'=>$n]);}public function down():void{$ids=DB::table('permissions')->whereIn('name',['serp_checks.view','serp_checks.manage'])->pluck('id');DB::table('permission_role')->whereIn('permission_id',$ids)->delete();DB::table('permissions')->whereIn('id',$ids)->delete();}};
|
||||
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('serp_checks', function (Blueprint $t) {
|
||||
$t->string('execution_mode', 16)->default('live')->after('provider');
|
||||
$t->string('origin', 16)->default('manual')->after('execution_mode');
|
||||
$t->timestamp('provider_task_posted_at')->nullable()->after('provider_reference');
|
||||
$t->timestamp('provider_last_polled_at')->nullable()->after('provider_task_posted_at');
|
||||
$t->unsignedSmallInteger('provider_poll_attempts')->default(0)->after('provider_last_polled_at');
|
||||
$t->decimal('provider_cost', 12, 6)->nullable()->after('provider_poll_attempts');
|
||||
$t->char('provider_cost_currency', 3)->nullable()->after('provider_cost');
|
||||
$t->unsignedInteger('provider_status_code')->nullable()->after('provider_cost_currency');
|
||||
$t->unique(['provider', 'provider_reference'], 'serp_checks_provider_reference_unique');
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('serp_checks', function (Blueprint $t) {
|
||||
$t->dropUnique('serp_checks_provider_reference_unique');
|
||||
$t->dropColumn(['execution_mode', 'origin', 'provider_task_posted_at', 'provider_last_polled_at', 'provider_poll_attempts', 'provider_cost', 'provider_cost_currency', 'provider_status_code']);
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,76 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('serp_operation_states', function (Blueprint $t) {
|
||||
$t->unsignedTinyInteger('id')->primary();
|
||||
$t->string('emergency_reason_code', 64)->nullable();
|
||||
$t->timestamp('emergency_stopped_at')->nullable()->index();
|
||||
$t->foreignId('emergency_actor_id')->nullable()->constrained('users')->nullOnDelete();
|
||||
$t->timestamp('last_health_at')->nullable();
|
||||
$t->bigInteger('last_balance_micros')->nullable();
|
||||
$t->unsignedInteger('last_provider_status_code')->nullable();
|
||||
$t->timestamp('last_provider_success_at')->nullable();
|
||||
$t->string('last_error_category', 64)->nullable();
|
||||
$t->timestamps();
|
||||
});
|
||||
DB::table('serp_operation_states')->insert(['id' => 1, 'created_at' => now(), 'updated_at' => now()]);
|
||||
Schema::create('serp_budget_entries', function (Blueprint $t) {
|
||||
$t->id();
|
||||
$t->string('reservation_key', 191)->unique();
|
||||
$t->foreignId('serp_check_id')->nullable()->constrained()->restrictOnDelete();
|
||||
$t->string('mode', 16);
|
||||
$t->unsignedBigInteger('reserved_micros');
|
||||
$t->unsignedBigInteger('actual_micros')->nullable();
|
||||
$t->char('currency', 3)->default('USD');
|
||||
$t->string('provider_task_id', 191)->nullable()->unique();
|
||||
$t->timestamp('reserved_at')->index();
|
||||
$t->timestamp('reconciled_at')->nullable();
|
||||
$t->timestamps();
|
||||
$t->index(['mode', 'reserved_at']);
|
||||
});
|
||||
Schema::create('serp_operation_audits', function (Blueprint $t) {
|
||||
$t->id();
|
||||
$t->foreignId('actor_user_id')->nullable()->constrained('users')->nullOnDelete();
|
||||
$t->string('action', 96)->index();
|
||||
$t->uuid('correlation_id')->index();
|
||||
$t->json('context')->nullable();
|
||||
$t->timestamps();
|
||||
});
|
||||
Schema::table('serp_checks', function (Blueprint $t) {
|
||||
$t->timestamp('provider_next_poll_at')->nullable()->after('provider_last_polled_at')->index();
|
||||
});
|
||||
$now = now();
|
||||
foreach ([['serp_operations.view', 'SERP operasyonlarını görüntüleme'], ['serp_operations.manage', 'SERP operasyonlarını yönetme'], ['serp_operations.emergency_stop', 'SERP acil durdurma yönetimi']] as [$name,$label]) {
|
||||
DB::table('permissions')->updateOrInsert(['name' => $name], ['label' => $label, 'created_at' => $now, 'updated_at' => $now]);
|
||||
}$roles = DB::table('roles')->pluck('id', 'name');
|
||||
$perms = DB::table('permissions')->pluck('id', 'name');
|
||||
foreach (['support', 'admin', 'super_admin'] as $role) {
|
||||
if (! isset($roles[$role])) {
|
||||
continue;
|
||||
}
|
||||
DB::table('permission_role')->updateOrInsert(['role_id' => $roles[$role], 'permission_id' => $perms['serp_operations.view']], ['created_at' => $now, 'updated_at' => $now]);
|
||||
}foreach (['serp_operations.manage', 'serp_operations.emergency_stop'] as $name) {
|
||||
if (! isset($roles['super_admin'])) {
|
||||
continue;
|
||||
}
|
||||
DB::table('permission_role')->updateOrInsert(['role_id' => $roles['super_admin'], 'permission_id' => $perms[$name]], ['created_at' => $now, 'updated_at' => $now]);
|
||||
}
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('serp_checks', fn (Blueprint $t) => $t->dropColumn('provider_next_poll_at'));
|
||||
Schema::dropIfExists('serp_operation_audits');
|
||||
Schema::dropIfExists('serp_budget_entries');
|
||||
Schema::dropIfExists('serp_operation_states');
|
||||
DB::table('permissions')->whereIn('name', ['serp_operations.view', 'serp_operations.manage', 'serp_operations.emergency_stop'])->delete();
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('serp_operation_states', function (Blueprint $t) {
|
||||
$t->timestamp('ramp_started_at')->nullable()->after('last_error_category')->index();
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('serp_operation_states', fn (Blueprint $t) => $t->dropColumn('ramp_started_at'));
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration {
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('users', fn (Blueprint $table) => $table->string('locale', 2)->nullable()->after('email'));
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('users', fn (Blueprint $table) => $table->dropColumn('locale'));
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration {
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('role_assignment_audits', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('actor_user_id')->nullable()->constrained('users')->nullOnDelete();
|
||||
$table->foreignId('subject_user_id')->constrained('users')->cascadeOnDelete();
|
||||
$table->uuid('correlation_id')->index();
|
||||
$table->json('previous_roles'); $table->json('new_roles');
|
||||
$table->json('added_roles'); $table->json('removed_roles');
|
||||
$table->string('result', 32); $table->timestamps();
|
||||
});
|
||||
}
|
||||
public function down(): void { Schema::dropIfExists('role_assignment_audits'); }
|
||||
};
|
||||
@@ -0,0 +1,3 @@
|
||||
<?php
|
||||
use Illuminate\Database\Migrations\Migration;use Illuminate\Database\Schema\Blueprint;use Illuminate\Support\Facades\Schema;
|
||||
return new class extends Migration{public function up():void{Schema::create('keyword_audits',function(Blueprint $t){$t->id();$t->foreignId('actor_user_id')->nullable()->constrained('users')->nullOnDelete();$t->foreignId('keyword_id')->nullable()->constrained('keywords')->nullOnDelete();$t->foreignId('project_id')->constrained()->restrictOnDelete();$t->string('action',40)->index();$t->uuid('correlation_id')->index();$t->json('before')->nullable();$t->json('after')->nullable();$t->timestamps();});}public function down():void{Schema::dropIfExists('keyword_audits');}};
|
||||
@@ -0,0 +1,3 @@
|
||||
<?php
|
||||
use Illuminate\Database\Migrations\Migration;use Illuminate\Database\Schema\Blueprint;use Illuminate\Support\Facades\Schema;
|
||||
return new class extends Migration{public function up():void{Schema::create('project_competitors',function(Blueprint$t){$t->id();$t->ulid('ulid')->unique();$t->foreignId('project_id')->constrained()->restrictOnDelete();$t->string('name',150);$t->string('domain',253);$t->string('normalized_domain',253);$t->string('status',20)->default('active')->index();$t->timestamp('archived_at')->nullable()->index();$t->foreignId('created_by')->nullable()->constrained('users')->nullOnDelete();$t->timestamps();$t->unique(['project_id','normalized_domain'],'project_competitors_domain_unique');$t->index(['project_id','status','archived_at'],'project_competitors_active_index');});Schema::create('competitor_audits',function(Blueprint$t){$t->id();$t->foreignId('actor_user_id')->nullable()->constrained('users')->nullOnDelete();$t->foreignId('project_id')->constrained()->restrictOnDelete();$t->foreignId('competitor_id')->nullable()->constrained('project_competitors')->nullOnDelete();$t->string('action',40)->index();$t->uuid('correlation_id')->index();$t->json('before')->nullable();$t->json('after')->nullable();$t->timestamps();});}public function down():void{Schema::dropIfExists('competitor_audits');Schema::dropIfExists('project_competitors');}};
|
||||
@@ -0,0 +1,3 @@
|
||||
<?php
|
||||
use Illuminate\Database\Migrations\Migration;use Illuminate\Database\Schema\Blueprint;use Illuminate\Support\Facades\Schema;
|
||||
return new class extends Migration{public function up():void{Schema::create('profile_audits',function(Blueprint$t){$t->id();$t->foreignId('actor_user_id')->nullable()->constrained('users')->nullOnDelete();$t->string('action',50)->index();$t->uuid('correlation_id')->index();$t->json('before')->nullable();$t->json('after')->nullable();$t->string('result',20)->default('success');$t->timestamps();});}public function down():void{Schema::dropIfExists('profile_audits');}};
|
||||
@@ -0,0 +1,3 @@
|
||||
<?php
|
||||
use Illuminate\Database\Migrations\Migration;use Illuminate\Database\Schema\Blueprint;use Illuminate\Support\Facades\Schema;
|
||||
return new class extends Migration{public function up():void{Schema::create('user_settings',function(Blueprint$t){$t->id();$t->foreignId('user_id')->unique()->constrained()->cascadeOnDelete();$t->string('theme',10)->default('system');$t->string('timezone',64)->default('Europe/Istanbul');$t->string('date_format',20)->default('DD.MM.YYYY');$t->string('time_format',10)->default('24');$t->string('default_report_range',20)->default('30_days');$t->foreignId('default_project_id')->nullable()->constrained('projects')->nullOnDelete();$t->unsignedSmallInteger('per_page')->default(25);$t->boolean('in_app_notifications')->default(true);$t->boolean('reduced_motion')->default(false);$t->timestamps();});}public function down():void{Schema::dropIfExists('user_settings');}};
|
||||
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('users', fn (Blueprint $table) => $table->softDeletes());
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('users', fn (Blueprint $table) => $table->dropSoftDeletes());
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('earn_members', function (Blueprint $table): void {
|
||||
$table->id();
|
||||
$table->ulid('ulid')->unique();
|
||||
$table->string('name');
|
||||
$table->string('email')->unique();
|
||||
$table->string('password');
|
||||
$table->string('status', 20)->default('pending')->index();
|
||||
$table->timestamp('email_verified_at')->nullable();
|
||||
$table->timestamp('last_login_at')->nullable();
|
||||
$table->ipAddress('last_login_ip')->nullable();
|
||||
$table->rememberToken();
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('earn_members');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('earn_audits', function (Blueprint $table): void {
|
||||
$table->id();
|
||||
$table->foreignId('earn_member_id')->nullable()->constrained()->nullOnDelete();
|
||||
$table->string('event', 50)->index();
|
||||
$table->ipAddress('ip_address')->nullable();
|
||||
$table->json('metadata')->nullable();
|
||||
$table->timestamp('created_at')->useCurrent();
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('earn_audits');
|
||||
}
|
||||
};
|
||||
@@ -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
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('earn_legal_acceptances', function (Blueprint $table): void {
|
||||
$table->id();
|
||||
$table->foreignId('earn_member_id')->constrained()->restrictOnDelete();
|
||||
$table->string('document_type', 30);
|
||||
$table->string('document_version', 50);
|
||||
$table->timestamp('accepted_at');
|
||||
$table->ipAddress('ip_address')->nullable();
|
||||
$table->string('user_agent', 1000)->nullable();
|
||||
$table->timestamps();
|
||||
$table->unique(['earn_member_id', 'document_type', 'document_version'], 'earn_legal_acceptance_unique');
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('earn_legal_acceptances');
|
||||
}
|
||||
};
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('personal_access_tokens', function (Blueprint $table): void {
|
||||
$table->string('token_hint', 16)->nullable()->after('token');
|
||||
$table->timestamp('revoked_at')->nullable()->after('expires_at');
|
||||
$table->index(['tokenable_type', 'tokenable_id', 'revoked_at', 'expires_at'], 'pat_earn_active_idx');
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('personal_access_tokens', function (Blueprint $table): void {
|
||||
$table->dropIndex('pat_earn_active_idx');
|
||||
$table->dropColumn(['token_hint', 'revoked_at']);
|
||||
});
|
||||
}
|
||||
};
|
||||
+28
@@ -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
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('personal_access_tokens', function (Blueprint $table): void {
|
||||
$table->boolean('is_active')->default(true)->after('abilities');
|
||||
$table->softDeletes()->after('revoked_at');
|
||||
$table->index(['tokenable_type', 'tokenable_id', 'deleted_at'], 'pat_owner_deleted_idx');
|
||||
$table->index(['is_active', 'revoked_at', 'expires_at'], 'pat_lifecycle_idx');
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('personal_access_tokens', function (Blueprint $table): void {
|
||||
$table->dropIndex('pat_owner_deleted_idx');
|
||||
$table->dropIndex('pat_lifecycle_idx');
|
||||
$table->dropSoftDeletes();
|
||||
$table->dropColumn('is_active');
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('personal_access_tokens', function (Blueprint $table): void {
|
||||
$table->char('device_id_hash', 64)->nullable()->after('token_hint');
|
||||
$table->string('device_id_preview', 24)->nullable()->after('device_id_hash');
|
||||
$table->timestamp('device_bound_at')->nullable()->after('device_id_preview');
|
||||
$table->string('first_ip', 45)->nullable()->after('device_bound_at');
|
||||
$table->string('last_ip', 45)->nullable()->after('first_ip');
|
||||
$table->timestamp('last_seen_at')->nullable()->after('last_ip');
|
||||
$table->boolean('device_mismatch_seen')->default(false)->after('last_seen_at');
|
||||
$table->index('device_id_hash', 'pat_device_hash_idx');
|
||||
});
|
||||
Schema::create('earn_api_access_logs', function (Blueprint $table): void {
|
||||
$table->bigIncrements('id');
|
||||
$table->foreignId('earn_member_id')->nullable()->constrained('earn_members')->nullOnDelete();
|
||||
$table->unsignedBigInteger('personal_access_token_id')->nullable();
|
||||
$table->string('token_preview', 16)->nullable();
|
||||
$table->string('event', 48);
|
||||
$table->char('device_id_hash', 64)->nullable();
|
||||
$table->string('device_id_preview', 24)->nullable();
|
||||
$table->string('ip_address', 45)->nullable();
|
||||
$table->string('user_agent', 255)->nullable();
|
||||
$table->string('http_method', 10);
|
||||
$table->string('route_name', 100)->nullable();
|
||||
$table->unsignedSmallInteger('response_status');
|
||||
$table->string('failure_code', 48)->nullable();
|
||||
$table->timestamp('occurred_at');
|
||||
$table->timestamp('created_at')->nullable();
|
||||
$table->foreign('personal_access_token_id')->references('id')->on('personal_access_tokens')->nullOnDelete();
|
||||
$table->index(['earn_member_id', 'occurred_at'], 'earn_access_member_time_idx');
|
||||
$table->index(['personal_access_token_id', 'occurred_at'], 'earn_access_token_time_idx');
|
||||
$table->index(['event', 'occurred_at'], 'earn_access_event_time_idx');
|
||||
$table->index('occurred_at', 'earn_access_retention_idx');
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('earn_api_access_logs');
|
||||
Schema::table('personal_access_tokens', function (Blueprint $table): void {
|
||||
$table->dropIndex('pat_device_hash_idx');
|
||||
$table->dropColumn(['device_id_hash', 'device_id_preview', 'device_bound_at', 'first_ip', 'last_ip', 'last_seen_at', 'device_mismatch_seen']);
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,63 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Görevlerin müşteri, Earn üyesi, token ve cihaz atamalarını ve idempotent sonuçlarını oluşturur.
|
||||
*
|
||||
* @author Gökhan Engin - İletişim : https://bit.ly/YazılımUzmanı
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
// Görev dağıtım sahipliğini ve cihaz kilidini tanımlar.
|
||||
// Yazar: Gökhan Engin - İletişim : https://bit.ly/YazılımUzmanı
|
||||
Schema::create('earn_task_assignments', function (Blueprint $table): void {
|
||||
$table->id();
|
||||
$table->string('task_id', 64)->unique();
|
||||
$table->foreignId('user_id')->constrained()->cascadeOnDelete();
|
||||
$table->foreignId('earn_member_id')->nullable()->constrained('earn_members')->nullOnDelete();
|
||||
$table->unsignedBigInteger('personal_access_token_id')->nullable();
|
||||
$table->char('device_id_hash', 64);
|
||||
$table->string('url', 2048);
|
||||
$table->unsignedSmallInteger('duration_seconds');
|
||||
$table->timestamp('assigned_at');
|
||||
$table->timestamps();
|
||||
$table->foreign('personal_access_token_id')->references('id')->on('personal_access_tokens')->nullOnDelete();
|
||||
$table->index(['user_id', 'assigned_at'], 'earn_task_assignment_user_idx');
|
||||
$table->index(['personal_access_token_id', 'device_id_hash'], 'earn_task_assignment_client_idx');
|
||||
});
|
||||
|
||||
// Her atama için tek ve müşteriyle sorgulanabilir sonuç tanımlar.
|
||||
// Yazar: Gökhan Engin - İletişim : https://bit.ly/YazılımUzmanı
|
||||
Schema::create('earn_task_results', function (Blueprint $table): void {
|
||||
$table->id();
|
||||
$table->foreignId('earn_task_assignment_id')->unique()->constrained('earn_task_assignments')->cascadeOnDelete();
|
||||
$table->foreignId('user_id')->constrained()->cascadeOnDelete();
|
||||
$table->foreignId('earn_member_id')->nullable()->constrained('earn_members')->nullOnDelete();
|
||||
$table->unsignedBigInteger('personal_access_token_id')->nullable();
|
||||
$table->char('device_id_hash', 64);
|
||||
$table->boolean('completed');
|
||||
$table->unsignedSmallInteger('response_code')->nullable();
|
||||
$table->string('error_message', 500)->nullable();
|
||||
$table->timestamp('submitted_at');
|
||||
$table->timestamps();
|
||||
$table->foreign('personal_access_token_id')->references('id')->on('personal_access_tokens')->nullOnDelete();
|
||||
$table->index(['user_id', 'submitted_at'], 'earn_task_result_user_idx');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Görev sonucu ve atama tablolarını bağımlılık sırasıyla kaldırır.
|
||||
*
|
||||
* @author Gökhan Engin - İletişim : https://bit.ly/YazılımUzmanı
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('earn_task_results');
|
||||
Schema::dropIfExists('earn_task_assignments');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use App\Models\User;
|
||||
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
class DatabaseSeeder extends Seeder
|
||||
{
|
||||
use WithoutModelEvents;
|
||||
|
||||
/**
|
||||
* Seed the application's database.
|
||||
*/
|
||||
public function run(): void
|
||||
{
|
||||
// User::factory(10)->create();
|
||||
|
||||
User::factory()->create([
|
||||
'name' => 'Test User',
|
||||
'email' => 'test@example.com',
|
||||
]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user