init
Some checks failed
Tests / PHP 8.2 (push) Has been cancelled
Tests / PHP 8.3 (push) Has been cancelled
Tests / PHP 8.4 (push) Has been cancelled

This commit is contained in:
jiangdong.cheng
2026-02-11 17:28:36 +08:00
parent dcb82557c7
commit aa16c9f8c2
162 changed files with 22333 additions and 0 deletions

View File

@@ -0,0 +1,55 @@
<?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
{
if (! Schema::hasTable('users')) {
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();
});
}
if (! Schema::hasTable('password_reset_tokens')) {
Schema::create('password_reset_tokens', function (Blueprint $table) {
$table->string('email')->primary();
$table->string('token');
$table->timestamp('created_at')->nullable();
});
}
if (! Schema::hasTable('sessions')) {
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');
}
};

View File

@@ -0,0 +1,39 @@
<?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
{
if (! Schema::hasTable('cache')) {
Schema::create('cache', function (Blueprint $table) {
$table->string('key')->primary();
$table->mediumText('value');
$table->integer('expiration')->index();
});
}
if (! Schema::hasTable('cache_locks')) {
Schema::create('cache_locks', function (Blueprint $table) {
$table->string('key')->primary();
$table->string('owner');
$table->integer('expiration')->index();
});
}
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('cache');
Schema::dropIfExists('cache_locks');
}
};

View File

@@ -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
{
/**
* Run the migrations.
*/
public function up(): void
{
if (! Schema::hasTable('jobs')) {
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');
});
}
if (! Schema::hasTable('job_batches')) {
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();
});
}
if (! Schema::hasTable('failed_jobs')) {
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');
}
};

View File

@@ -0,0 +1,30 @@
<?php
declare(strict_types=1);
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('categories', function (Blueprint $table): void {
$table->id();
$table->string('type', 32);
$table->string('name', 120);
$table->string('slug')->unique();
$table->text('description')->nullable();
$table->boolean('is_active')->default(true);
$table->timestamps();
$table->index(['type', 'is_active']);
});
}
public function down(): void
{
Schema::dropIfExists('categories');
}
};

View File

@@ -0,0 +1,29 @@
<?php
declare(strict_types=1);
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('tags', function (Blueprint $table): void {
$table->id();
$table->string('name', 120);
$table->string('slug')->unique();
$table->text('description')->nullable();
$table->boolean('is_active')->default(true);
$table->timestamps();
$table->index('is_active');
});
}
public function down(): void
{
Schema::dropIfExists('tags');
}
};

View File

@@ -0,0 +1,32 @@
<?php
declare(strict_types=1);
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('sources', function (Blueprint $table): void {
$table->id();
$table->string('name', 150);
$table->string('domain', 255)->unique();
$table->string('type', 32)->default('media');
$table->string('trust_level', 32)->default('trusted_media');
$table->boolean('is_whitelisted')->default(true);
$table->boolean('crawl_allowed')->default(false);
$table->text('note')->nullable();
$table->timestamps();
$table->index(['is_whitelisted', 'trust_level']);
});
}
public function down(): void
{
Schema::dropIfExists('sources');
}
};

View File

@@ -0,0 +1,50 @@
<?php
declare(strict_types=1);
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('tools', function (Blueprint $table): void {
$table->id();
$table->foreignId('category_id')->nullable()->constrained()->nullOnDelete();
$table->foreignId('source_id')->nullable()->constrained()->nullOnDelete();
$table->string('name', 160);
$table->string('slug')->unique();
$table->string('summary', 260);
$table->longText('description')->nullable();
$table->string('official_url', 2048)->nullable();
$table->string('pricing_type', 32)->default('freemium');
$table->string('platform', 64)->nullable();
$table->string('language', 64)->nullable();
$table->boolean('has_api')->default(false);
$table->string('source_level', 32)->default('unknown');
$table->timestamp('last_verified_at')->nullable();
$table->string('status', 32)->default('draft');
$table->boolean('is_stale')->default(false);
$table->text('stale_note')->nullable();
$table->foreignId('alternative_tool_id')->nullable()->constrained('tools')->nullOnDelete();
$table->string('seo_title', 180)->nullable();
$table->string('seo_description', 320)->nullable();
$table->string('h1', 180)->nullable();
$table->string('canonical_url', 2048)->nullable();
$table->timestamp('published_at')->nullable();
$table->timestamps();
$table->index(['status', 'is_stale', 'published_at']);
$table->index(['category_id', 'pricing_type']);
$table->index(['source_level', 'last_verified_at']);
$table->fullText(['name', 'summary', 'description']);
});
}
public function down(): void
{
Schema::dropIfExists('tools');
}
};

View File

@@ -0,0 +1,55 @@
<?php
declare(strict_types=1);
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('ai_models', function (Blueprint $table): void {
$table->id();
$table->foreignId('category_id')->nullable()->constrained()->nullOnDelete();
$table->foreignId('source_id')->nullable()->constrained()->nullOnDelete();
$table->string('name', 160);
$table->string('slug')->unique();
$table->string('provider', 120)->nullable();
$table->string('summary', 260);
$table->longText('description')->nullable();
$table->string('modality', 64)->default('text');
$table->unsignedInteger('context_window')->nullable();
$table->decimal('price_input', 12, 6)->nullable();
$table->decimal('price_output', 12, 6)->nullable();
$table->string('deployment_mode', 32)->default('api');
$table->unsignedTinyInteger('effectiveness_score')->default(60);
$table->unsignedTinyInteger('price_score')->default(60);
$table->unsignedTinyInteger('speed_score')->default(60);
$table->unsignedTinyInteger('total_score')->default(60);
$table->string('source_level', 32)->default('unknown');
$table->timestamp('last_verified_at')->nullable();
$table->string('status', 32)->default('draft');
$table->boolean('is_stale')->default(false);
$table->text('stale_note')->nullable();
$table->foreignId('alternative_model_id')->nullable()->constrained('ai_models')->nullOnDelete();
$table->string('seo_title', 180)->nullable();
$table->string('seo_description', 320)->nullable();
$table->string('h1', 180)->nullable();
$table->string('canonical_url', 2048)->nullable();
$table->timestamp('published_at')->nullable();
$table->timestamps();
$table->index(['status', 'is_stale', 'published_at']);
$table->index(['modality', 'deployment_mode']);
$table->index(['total_score', 'effectiveness_score']);
$table->fullText(['name', 'summary', 'description']);
});
}
public function down(): void
{
Schema::dropIfExists('ai_models');
}
};

View File

@@ -0,0 +1,45 @@
<?php
declare(strict_types=1);
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('articles', function (Blueprint $table): void {
$table->id();
$table->foreignId('category_id')->nullable()->constrained()->nullOnDelete();
$table->foreignId('source_id')->nullable()->constrained()->nullOnDelete();
$table->string('title', 200);
$table->string('slug')->unique();
$table->string('excerpt', 320);
$table->longText('body');
$table->string('source_name', 160)->nullable();
$table->string('source_url', 2048)->nullable();
$table->string('source_level', 32)->default('unknown');
$table->timestamp('last_verified_at')->nullable();
$table->string('status', 32)->default('draft');
$table->boolean('is_stale')->default(false);
$table->text('stale_note')->nullable();
$table->string('seo_title', 180)->nullable();
$table->string('seo_description', 320)->nullable();
$table->string('h1', 180)->nullable();
$table->string('canonical_url', 2048)->nullable();
$table->timestamp('published_at')->nullable();
$table->timestamps();
$table->index(['status', 'published_at']);
$table->index(['is_stale', 'last_verified_at']);
$table->fullText(['title', 'excerpt', 'body']);
});
}
public function down(): void
{
Schema::dropIfExists('articles');
}
};

View File

@@ -0,0 +1,39 @@
<?php
declare(strict_types=1);
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('guides', function (Blueprint $table): void {
$table->id();
$table->foreignId('category_id')->nullable()->constrained()->nullOnDelete();
$table->string('title', 200);
$table->string('slug')->unique();
$table->string('excerpt', 320);
$table->longText('body');
$table->string('difficulty', 32)->default('beginner');
$table->string('status', 32)->default('draft');
$table->string('seo_title', 180)->nullable();
$table->string('seo_description', 320)->nullable();
$table->string('h1', 180)->nullable();
$table->string('canonical_url', 2048)->nullable();
$table->timestamp('published_at')->nullable();
$table->timestamps();
$table->index(['status', 'published_at']);
$table->index(['difficulty', 'published_at']);
$table->fullText(['title', 'excerpt', 'body']);
});
}
public function down(): void
{
Schema::dropIfExists('guides');
}
};

View File

@@ -0,0 +1,29 @@
<?php
declare(strict_types=1);
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('entity_tag_maps', function (Blueprint $table): void {
$table->id();
$table->foreignId('tag_id')->constrained()->cascadeOnDelete();
$table->string('entity_type', 64);
$table->unsignedBigInteger('entity_id');
$table->timestamps();
$table->unique(['tag_id', 'entity_type', 'entity_id'], 'entity_tag_maps_unique');
$table->index(['entity_type', 'entity_id']);
});
}
public function down(): void
{
Schema::dropIfExists('entity_tag_maps');
}
};

View File

@@ -0,0 +1,36 @@
<?php
declare(strict_types=1);
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
public function up(): void
{
if (! Schema::hasTable('change_logs')) {
Schema::create('change_logs', function (Blueprint $table): void {
$table->id();
$table->string('entity_type', 64);
$table->unsignedBigInteger('entity_id');
$table->string('action', 64);
$table->json('before_data')->nullable();
$table->json('after_data')->nullable();
$table->unsignedBigInteger('changed_by')->nullable();
$table->timestamp('changed_at')->useCurrent();
$table->timestamps();
$table->index(['entity_type', 'entity_id', 'changed_at']);
$table->index('action');
$table->index('changed_by');
});
}
}
public function down(): void
{
Schema::dropIfExists('change_logs');
}
};

View File

@@ -0,0 +1,28 @@
<?php
declare(strict_types=1);
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('tools', function (Blueprint $table): void {
if (!Schema::hasColumn('tools', 'logo_url')) {
$table->string('logo_url', 2048)->nullable()->after('official_url');
}
});
}
public function down(): void
{
Schema::table('tools', function (Blueprint $table): void {
if (Schema::hasColumn('tools', 'logo_url')) {
$table->dropColumn('logo_url');
}
});
}
};