Files
Laravel/database/migrations/2024_01_01_000004_create_resumes_table.php
David Melendez e25d53d054 init commit
2026-01-14 22:38:44 +01:00

65 lines
2.8 KiB
PHP

<?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('resumes', function (Blueprint $table) {
$table->id();
$table->foreignId('user_id')->constrained()->onDelete('cascade');
$table->string('title');
$table->text('description')->nullable();
$table->enum('template', ['professional', 'modern', 'executive', 'minimal', 'technical'])->default('professional');
$table->json('content')->nullable(); // Resume content as JSON
$table->json('settings')->nullable(); // Template settings as JSON
$table->enum('status', ['draft', 'published', 'archived'])->default('draft');
$table->boolean('is_public')->default(false);
$table->string('public_url')->nullable()->unique();
$table->timestamp('published_at')->nullable();
$table->integer('view_count')->default(0);
$table->integer('download_count')->default(0);
$table->timestamp('last_viewed_at')->nullable();
$table->timestamp('last_downloaded_at')->nullable();
$table->integer('completion_percentage')->default(0);
$table->json('completion_sections')->nullable(); // Which sections are complete
$table->string('pdf_path')->nullable(); // Path to generated PDF
$table->timestamp('pdf_generated_at')->nullable();
$table->integer('pdf_version')->default(1);
$table->json('analytics')->nullable(); // Analytics data
$table->json('feedback')->nullable(); // User feedback/notes
$table->boolean('allow_comments')->default(false);
$table->string('password')->nullable(); // Password protection
$table->timestamp('expires_at')->nullable(); // Public link expiration
$table->json('share_settings')->nullable(); // Sharing permissions
$table->string('slug')->nullable(); // SEO-friendly URL
$table->json('seo_meta')->nullable(); // SEO metadata
$table->timestamps();
$table->softDeletes(); // Soft delete for data recovery
// Indexes for performance
$table->index(['user_id', 'status']);
$table->index(['is_public', 'published_at']);
$table->index(['template']);
$table->index(['created_at']);
$table->index(['view_count']);
$table->index(['slug']);
$table->index(['public_url']);
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('resumes');
}
};