First Commit

This commit is contained in:
marco
2026-09-01 09:22:30 -03:00
commit a43ae23eb4
407 changed files with 36138 additions and 0 deletions
@@ -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,59 @@
<?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->unsignedSmallInteger('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->string('connection');
$table->string('queue');
$table->longText('payload');
$table->longText('exception');
$table->timestamp('failed_at')->useCurrent();
$table->index(['connection', 'queue', 'failed_at']);
});
}
/**
* 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::table('users', function (Blueprint $table) {
$table->enum('role', ['superadmin', 'user', 'pending'])->default('pending')->after('password');
$table->boolean('is_approved')->default(false)->after('role');
$table->index('role');
$table->index('is_approved');
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('users', function (Blueprint $table) {
$table->dropIndex(['role']);
$table->dropIndex(['is_approved']);
$table->dropColumn(['role', 'is_approved']);
});
}
};
@@ -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('ai_providers', function (Blueprint $table) {
$table->id();
$table->string('name');
$table->string('slug')->unique();
$table->text('description')->nullable();
$table->string('api_key')->nullable();
$table->string('base_url');
$table->boolean('is_active')->default(true);
$table->json('config')->nullable();
$table->timestamps();
$table->softDeletes();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('ai_providers');
}
};
@@ -0,0 +1,42 @@
<?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('ai_models', function (Blueprint $table) {
$table->id();
$table->unsignedBigInteger('provider_id')->index();
$table->string('name');
$table->string('slug');
$table->integer('max_tokens')->nullable();
$table->boolean('temperature_support')->default(true);
$table->boolean('is_active')->default(true);
$table->timestamps();
$table->softDeletes();
$table->unique(['provider_id', 'slug']);
$table->index(['provider_id', 'is_active']);
$table->foreign('provider_id')->references('id')->on('ai_providers')->onDelete('cascade');
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('ai_models', function (Blueprint $table) {
$table->dropForeign(['provider_id']);
});
Schema::dropIfExists('ai_models');
}
};
@@ -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
{
Schema::create('prompt_projects', function (Blueprint $table) {
$table->id();
$table->unsignedBigInteger('user_id')->nullable()->index();
$table->string('title');
$table->text('objective')->nullable();
$table->text('context')->nullable();
$table->text('persona')->nullable();
$table->text('tone')->nullable();
$table->text('constraints')->nullable();
$table->text('output_format')->nullable();
$table->json('examples')->nullable();
$table->json('variables')->nullable();
$table->decimal('temperature', 3, 2)->nullable();
$table->integer('max_tokens')->nullable();
$table->unsignedBigInteger('provider_id')->nullable()->index();
$table->unsignedBigInteger('model_id')->nullable()->index();
$table->text('generated_prompt')->nullable();
$table->string('status')->nullable();
$table->timestamps();
$table->softDeletes();
$table->index(['user_id', 'created_at']);
$table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
$table->foreign('provider_id')->references('id')->on('ai_providers')->onDelete('set null');
$table->foreign('model_id')->references('id')->on('ai_models')->onDelete('set null');
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('prompt_projects', function (Blueprint $table) {
$table->dropForeign(['model_id']);
$table->dropForeign(['provider_id']);
$table->dropForeign(['user_id']);
});
Schema::dropIfExists('prompt_projects');
}
};
@@ -0,0 +1,52 @@
<?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('prompt_generations', function (Blueprint $table) {
$table->id();
$table->unsignedBigInteger('project_id')->index();
$table->unsignedBigInteger('user_id')->index();
$table->unsignedBigInteger('provider_id')->index();
$table->unsignedBigInteger('model_id')->index();
$table->text('generated_prompt');
$table->json('input_data')->nullable();
$table->json('output_data')->nullable();
$table->integer('tokens_used')->nullable();
$table->decimal('generation_time', 8, 3)->nullable();
$table->string('status')->nullable();
$table->timestamps();
$table->softDeletes();
$table->index(['project_id', 'created_at']);
$table->index(['user_id', 'created_at']);
$table->foreign('project_id')->references('id')->on('prompt_projects')->onDelete('cascade');
$table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
$table->foreign('provider_id')->references('id')->on('ai_providers')->onDelete('cascade');
$table->foreign('model_id')->references('id')->on('ai_models')->onDelete('cascade');
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('prompt_generations', function (Blueprint $table) {
$table->dropForeign(['model_id']);
$table->dropForeign(['provider_id']);
$table->dropForeign(['user_id']);
$table->dropForeign(['project_id']);
});
Schema::dropIfExists('prompt_generations');
}
};
@@ -0,0 +1,36 @@
<?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('prompt_templates', function (Blueprint $table) {
$table->id();
$table->string('name');
$table->text('description')->nullable();
$table->string('category')->nullable();
$table->json('template_data');
$table->boolean('is_public')->default(false);
$table->foreignId('user_id')->nullable()->constrained()->nullOnDelete()->index();
$table->timestamps();
$table->softDeletes();
$table->index(['user_id', 'is_public']);
$table->index(['category', 'is_public']);
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('prompt_templates');
}
};
@@ -0,0 +1,58 @@
<?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('cookie_consents', function (Blueprint $table) {
$table->id();
$table->foreignId('user_id')->nullable()->constrained()->nullOnDelete();
$table->string('session_id')->nullable()->index();
$table->string('ip_address')->nullable();
$table->string('user_agent')->nullable();
$table->json('consents')->nullable();
$table->timestamp('accepted_at')->nullable();
$table->timestamps();
$table->index(['user_id', 'created_at']);
});
Schema::create('legal_documents', function (Blueprint $table) {
$table->id();
$table->string('type')->unique();
$table->string('title');
$table->text('content');
$table->string('version');
$table->timestamp('published_at')->nullable();
$table->foreignId('published_by')->nullable()->constrained('users')->nullOnDelete();
$table->timestamps();
$table->index(['type', 'version']);
});
Schema::create('user_document_acceptances', function (Blueprint $table) {
$table->id();
$table->foreignId('user_id')->constrained()->cascadeOnDelete();
$table->foreignId('legal_document_id')->constrained()->cascadeOnDelete();
$table->string('document_version');
$table->string('ip_address')->nullable();
$table->string('user_agent')->nullable();
$table->timestamp('accepted_at');
$table->timestamps();
$table->unique(['user_id', 'legal_document_id']);
$table->index(['user_id', 'accepted_at']);
});
}
public function down(): void
{
Schema::dropIfExists('user_document_acceptances');
Schema::dropIfExists('legal_documents');
Schema::dropIfExists('cookie_consents');
}
};
@@ -0,0 +1,26 @@
<?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('tutorial_lessons', function (Blueprint $table) {
$table->id();
$table->string('title');
$table->text('content');
$table->text('example_bad')->nullable();
$table->text('example_good')->nullable();
$table->integer('order')->default(0);
$table->timestamps();
});
}
public function down(): void
{
Schema::dropIfExists('tutorial_lessons');
}
};
@@ -0,0 +1,26 @@
<?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('tutorial_questions', function (Blueprint $table) {
$table->id();
$table->string('question');
$table->json('options');
$table->string('correct_answer');
$table->text('explanation')->nullable();
$table->integer('order')->default(0);
$table->timestamps();
});
}
public function down(): void
{
Schema::dropIfExists('tutorial_questions');
}
};
@@ -0,0 +1,30 @@
<?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('tutorial_user_progress', function (Blueprint $table) {
$table->id();
$table->foreignId('user_id')->constrained()->cascadeOnDelete();
$table->json('completed_lessons')->nullable();
$table->json('quiz_answers')->nullable();
$table->integer('quiz_score')->nullable();
$table->boolean('quiz_passed')->default(false);
$table->timestamp('quiz_completed_at')->nullable();
$table->timestamp('certificate_generated_at')->nullable();
$table->timestamps();
$table->unique('user_id');
});
}
public function down(): void
{
Schema::dropIfExists('tutorial_user_progress');
}
};
@@ -0,0 +1,22 @@
<?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('avatar')->nullable()->after('email');
});
}
public function down(): void
{
Schema::table('users', function (Blueprint $table) {
$table->dropColumn('avatar');
});
}
};
@@ -0,0 +1,36 @@
<?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('prompt_projects', function (Blueprint $table) {
$table->string('company_name')->nullable()->after('title');
$table->text('company_address')->nullable()->after('company_name');
$table->string('company_whatsapp')->nullable()->after('company_address');
$table->string('company_website')->nullable()->after('company_whatsapp');
$table->text('company_social_media')->nullable()->after('company_website');
$table->text('company_business_activities')->nullable()->after('company_social_media');
$table->text('company_services_products')->nullable()->after('company_business_activities');
});
}
public function down(): void
{
Schema::table('prompt_projects', function (Blueprint $table) {
$table->dropColumn([
'company_name',
'company_address',
'company_whatsapp',
'company_website',
'company_social_media',
'company_business_activities',
'company_services_products',
]);
});
}
};