Files
toolvana/app/Database/Migrations/2025-01-01-000001_CreateTools.php
deepseek beaf0e1f37 Toolvana: production-ready media tools platform (CodeIgniter 4)
- 134-tool registry with programmatic SEO (unique titles/H1/descriptions,
  JSON-LD graphs, sitemap index, canonical 301 enforcement via required filter)
- DB-backed job queue (SKIP LOCKED) with drivers: Ffmpeg, Images (GD),
  Pdf (qpdf/gs/poppler), Youtube (thumbnails), Qr (server-side PNG)
- Security: SSRF guard, MIME validation, rate limits, API-key auth,
  bcrypt admin login, security headers
- Admin panel: dashboard, tools/categories/guides CRUD, SEO audit,
  analytics, job inspector with retry, system health, feature flags
- Docker deployment (nginx + web/api FPM pools + scalable workers),
  PHPUnit suite (19 tests / 1139 assertions), PWA manifest + service worker
2026-08-23 07:10:30 +00:00

69 lines
3.9 KiB
PHP

<?php
declare(strict_types=1);
namespace App\Database\Migrations;
use CodeIgniter\Database\Migration;
/**
* The tool registry — the heart of the platform. Adding a tool is a
* database row, never a code change: routes, pages, sitemaps, search,
* related-links and the pipeline all read from this table.
*/
final class CreateTools extends Migration
{
public function up(): void
{
$this->forge->addField([
'id' => ['type' => 'INT', 'unsigned' => true, 'auto_increment' => true],
'category_id' => ['type' => 'INT', 'unsigned' => true],
// kind drives which UI/pipeline the page uses:
// url paste a URL (YouTube family)
// upload file in / file out
// text instant text utility (no processing queue)
'kind' => ['type' => 'ENUM', 'constraint' => ['url', 'upload', 'text'], 'default' => 'upload'],
// structured operation consumed by the pipeline drivers
'operation' => ['type' => 'VARCHAR', 'constraint' => 40, 'null' => true],
'slug' => ['type' => 'VARCHAR', 'constraint' => 120, 'unique' => true],
'name' => ['type' => 'VARCHAR', 'constraint' => 140],
'short_description' => ['type' => 'VARCHAR', 'constraint' => 320],
'description' => ['type' => 'TEXT', 'null' => true],
'input_formats' => ['type' => 'JSON', 'null' => true],
'output_formats' => ['type' => 'JSON', 'null' => true],
'primary_input_format' => ['type' => 'VARCHAR', 'constraint' => 16, 'null' => true],
'primary_output_format' => ['type' => 'VARCHAR', 'constraint' => 16, 'null' => true],
'icon' => ['type' => 'VARCHAR', 'constraint' => 32, 'default' => 'file'],
'seo_title' => ['type' => 'VARCHAR', 'constraint' => 190],
'seo_description' => ['type' => 'VARCHAR', 'constraint' => 320],
'h1' => ['type' => 'VARCHAR', 'constraint' => 190],
'intro' => ['type' => 'TEXT', 'null' => true],
'how_to' => ['type' => 'JSON', 'null' => true],
'faqs' => ['type' => 'JSON', 'null' => true],
'related_slugs' => ['type' => 'JSON', 'null' => true], // curated overrides first
'aliases' => ['type' => 'JSON', 'null' => true], // search aliases ("yt mp3")
'requires_binaries' => ['type' => 'JSON', 'null' => true], // ["ffmpeg"], ["qpdf"] ...
'accepts_mimes' => ['type' => 'JSON', 'null' => true], // upload validation
'max_upload_mb' => ['type' => 'INT', 'unsigned' => true, 'default' => 0], // 0 = site default
'popularity' => ['type' => 'INT', 'unsigned' => true, 'default' => 0],
'use_count' => ['type' => 'BIGINT', 'unsigned' => true, 'default' => 0],
'status' => ['type' => 'ENUM', 'constraint' => ['active', 'draft', 'inactive'], 'default' => 'active'],
'is_featured' => ['type' => 'TINYINT', 'constraint' => 1, 'default' => 0],
'sort_order' => ['type' => 'INT', 'unsigned' => true, 'default' => 0],
'created_at' => ['type' => 'DATETIME', 'null' => true],
'updated_at' => ['type' => 'DATETIME', 'null' => true],
]);
$this->forge->addPrimaryKey('id');
$this->forge->addKey('category_id');
$this->forge->addKey('status');
$this->forge->addKey(['status', 'popularity']);
$this->forge->addForeignKey('category_id', 'categories', 'id', 'CASCADE', 'CASCADE');
$this->forge->createTable('tools', true);
}
public function down(): void
{
$this->forge->dropTable('tools', true);
}
}