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
This commit is contained in:
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Database\Migrations;
|
||||
|
||||
use CodeIgniter\Database\Migration;
|
||||
|
||||
/**
|
||||
* Processing queue. States: queued -> processing -> completed | failed,
|
||||
* with cancelled and expired as terminal cleanup states.
|
||||
*/
|
||||
final class CreateJobs extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
$this->forge->addField([
|
||||
'id' => ['type' => 'CHAR', 'constraint' => 36],
|
||||
// anonymous, hashed — no raw identifiers are ever stored
|
||||
'session_id' => ['type' => 'VARCHAR', 'constraint' => 64],
|
||||
'ip_hash' => ['type' => 'CHAR', 'constraint' => 32],
|
||||
'tool_id' => ['type' => 'INT', 'unsigned' => true, 'null' => true],
|
||||
'operation' => ['type' => 'VARCHAR', 'constraint' => 40],
|
||||
'params' => ['type' => 'JSON', 'null' => true],
|
||||
'input_file' => ['type' => 'VARCHAR', 'constraint' => 255, 'null' => true],
|
||||
'input_name' => ['type' => 'VARCHAR', 'constraint' => 255, 'null' => true],
|
||||
'input_size' => ['type' => 'BIGINT', 'unsigned' => true, 'default' => 0],
|
||||
'input_mime' => ['type' => 'VARCHAR', 'constraint' => 100, 'null' => true],
|
||||
'output_file' => ['type' => 'VARCHAR', 'constraint' => 255, 'null' => true],
|
||||
'output_name' => ['type' => 'VARCHAR', 'constraint' => 255, 'null' => true],
|
||||
'output_size' => ['type' => 'BIGINT', 'unsigned' => true, 'default' => 0],
|
||||
'status' => ['type' => 'ENUM', 'constraint' => ['queued', 'processing', 'completed', 'failed', 'cancelled', 'expired'], 'default' => 'queued'],
|
||||
'progress' => ['type' => 'TINYINT', 'unsigned' => true, 'default' => 0],
|
||||
'stage' => ['type' => 'VARCHAR', 'constraint' => 32, 'default' => 'queued'],
|
||||
'error' => ['type' => 'TEXT', 'null' => true],
|
||||
'priority' => ['type' => 'TINYINT', 'constraint' => 3, 'default' => 5],
|
||||
'attempts' => ['type' => 'TINYINT', 'unsigned' => true, 'default' => 0],
|
||||
'source' => ['type' => 'ENUM', 'constraint' => ['web', 'api'], 'default' => 'web'],
|
||||
'download_count'=> ['type' => 'INT', 'unsigned' => true, 'default' => 0],
|
||||
'created_at' => ['type' => 'DATETIME', 'null' => true],
|
||||
'started_at' => ['type' => 'DATETIME', 'null' => true],
|
||||
'completed_at' => ['type' => 'DATETIME', 'null' => true],
|
||||
'expires_at' => ['type' => 'DATETIME', 'null' => true],
|
||||
]);
|
||||
$this->forge->addPrimaryKey('id');
|
||||
$this->forge->addKey('status');
|
||||
$this->forge->addKey('created_at');
|
||||
$this->forge->addKey('expires_at');
|
||||
$this->forge->addKey('session_id');
|
||||
$this->forge->addForeignKey('tool_id', 'tools', 'id', 'SET NULL', 'CASCADE');
|
||||
$this->forge->createTable('jobs', true);
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
$this->forge->dropTable('jobs', true);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user