feat: Initial commit for Saqel Platform architecture, backend, Docker, and documentation
This commit is contained in:
@@ -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');
|
||||
}
|
||||
};
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
<?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('role', 20)->default('student')->index();
|
||||
$table->string('api_token', 80)->unique()->nullable();
|
||||
$table->unsignedTinyInteger('grade')->nullable();
|
||||
$table->string('track', 20)->nullable();
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('users', function (Blueprint $table) {
|
||||
$table->dropColumn(['role', 'api_token', 'grade', 'track']);
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,64 @@
|
||||
<?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('subjects', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('name');
|
||||
$table->string('slug')->unique();
|
||||
$table->timestamps();
|
||||
});
|
||||
|
||||
Schema::create('courses', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('subject_id')->constrained()->cascadeOnDelete();
|
||||
$table->unsignedTinyInteger('grade');
|
||||
$table->string('track', 20);
|
||||
$table->string('title');
|
||||
$table->text('description')->nullable();
|
||||
$table->timestamps();
|
||||
});
|
||||
|
||||
Schema::create('lessons', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('course_id')->constrained()->cascadeOnDelete();
|
||||
$table->string('title');
|
||||
$table->unsignedInteger('order_index')->default(0);
|
||||
$table->string('video_id')->nullable();
|
||||
$table->unsignedInteger('duration_seconds')->default(0);
|
||||
$table->text('transcript')->nullable();
|
||||
$table->timestamps();
|
||||
});
|
||||
|
||||
Schema::create('concepts', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('subject_id')->constrained()->cascadeOnDelete();
|
||||
$table->string('name');
|
||||
$table->foreignId('remedial_lesson_id')->nullable()->constrained('lessons')->nullOnDelete();
|
||||
$table->timestamps();
|
||||
|
||||
$table->unique(['subject_id', 'name']);
|
||||
});
|
||||
|
||||
Schema::create('lesson_concept', function (Blueprint $table) {
|
||||
$table->foreignId('lesson_id')->constrained()->cascadeOnDelete();
|
||||
$table->foreignId('concept_id')->constrained()->cascadeOnDelete();
|
||||
$table->primary(['lesson_id', 'concept_id']);
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('lesson_concept');
|
||||
Schema::dropIfExists('concepts');
|
||||
Schema::dropIfExists('lessons');
|
||||
Schema::dropIfExists('courses');
|
||||
Schema::dropIfExists('subjects');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,43 @@
|
||||
<?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('quizzes', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('lesson_id')->constrained()->cascadeOnDelete();
|
||||
$table->string('title')->nullable();
|
||||
$table->unsignedInteger('trigger_seconds')->nullable();
|
||||
$table->timestamps();
|
||||
});
|
||||
|
||||
Schema::create('questions', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('quiz_id')->constrained()->cascadeOnDelete();
|
||||
$table->foreignId('concept_id')->nullable()->constrained()->nullOnDelete();
|
||||
$table->text('body');
|
||||
$table->text('explanation')->nullable();
|
||||
$table->timestamps();
|
||||
});
|
||||
|
||||
Schema::create('question_options', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('question_id')->constrained()->cascadeOnDelete();
|
||||
$table->text('body');
|
||||
$table->boolean('is_correct')->default(false);
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('question_options');
|
||||
Schema::dropIfExists('questions');
|
||||
Schema::dropIfExists('quizzes');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,61 @@
|
||||
<?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('lesson_progress', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('user_id')->constrained()->cascadeOnDelete();
|
||||
$table->foreignId('lesson_id')->constrained()->cascadeOnDelete();
|
||||
$table->unsignedInteger('last_position_seconds')->default(0);
|
||||
$table->unsignedTinyInteger('watched_percentage')->default(0);
|
||||
$table->timestamp('completed_at')->nullable();
|
||||
$table->timestamps();
|
||||
|
||||
$table->unique(['user_id', 'lesson_id']);
|
||||
});
|
||||
|
||||
Schema::create('quiz_attempts', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('user_id')->constrained()->cascadeOnDelete();
|
||||
$table->foreignId('quiz_id')->constrained()->cascadeOnDelete();
|
||||
$table->unsignedTinyInteger('score');
|
||||
$table->timestamps();
|
||||
});
|
||||
|
||||
Schema::create('answers', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('quiz_attempt_id')->constrained()->cascadeOnDelete();
|
||||
$table->foreignId('question_id')->constrained()->cascadeOnDelete();
|
||||
$table->foreignId('selected_option_id')->nullable()->constrained('question_options')->nullOnDelete();
|
||||
$table->boolean('is_correct');
|
||||
$table->unsignedInteger('time_spent_seconds')->default(0);
|
||||
$table->timestamps();
|
||||
});
|
||||
|
||||
Schema::create('concept_mastery', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('user_id')->constrained()->cascadeOnDelete();
|
||||
$table->foreignId('concept_id')->constrained()->cascadeOnDelete();
|
||||
$table->unsignedInteger('correct_count')->default(0);
|
||||
$table->unsignedInteger('wrong_count')->default(0);
|
||||
$table->decimal('mastery_score', 5, 2)->default(0);
|
||||
$table->timestamps();
|
||||
|
||||
$table->unique(['user_id', 'concept_id']);
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('concept_mastery');
|
||||
Schema::dropIfExists('answers');
|
||||
Schema::dropIfExists('quiz_attempts');
|
||||
Schema::dropIfExists('lesson_progress');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,32 @@
|
||||
<?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('guardian_student', function (Blueprint $table) {
|
||||
$table->foreignId('guardian_id')->constrained('users')->cascadeOnDelete();
|
||||
$table->foreignId('student_id')->constrained('users')->cascadeOnDelete();
|
||||
$table->primary(['guardian_id', 'student_id']);
|
||||
});
|
||||
|
||||
Schema::create('ai_reports', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('user_id')->constrained()->cascadeOnDelete();
|
||||
$table->string('type', 40)->index();
|
||||
$table->json('payload');
|
||||
$table->text('summary')->nullable();
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('ai_reports');
|
||||
Schema::dropIfExists('guardian_student');
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user