This commit is contained in:
Saufi
2026-06-02 17:35:45 +08:00
commit 4ef99b1f81
148 changed files with 21134 additions and 0 deletions

View File

@@ -0,0 +1,57 @@
<?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('departments', function (Blueprint $table) {
$table->id();
$table->string('name');
$table->string('code', 50)->nullable()->unique();
$table->boolean('is_active')->default(true);
$table->timestamps();
});
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->enum('role', ['admin', 'user'])->default('user');
$table->foreignId('department_id')->nullable()->constrained('departments')->nullOnDelete();
$table->boolean('is_active')->default(true);
$table->timestamp('last_login_at')->nullable();
$table->rememberToken();
$table->timestamps();
$table->softDeletes();
});
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();
});
}
public function down(): void
{
Schema::dropIfExists('sessions');
Schema::dropIfExists('password_reset_tokens');
Schema::dropIfExists('users');
Schema::dropIfExists('departments');
}
};

View File

@@ -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');
}
};

View File

@@ -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');
}
};

View File

@@ -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::create('audit_logs', function (Blueprint $table) {
$table->id();
$table->foreignId('actor_user_id')->nullable()->constrained('users')->nullOnDelete();
$table->string('actor_role', 50)->nullable();
$table->string('action', 100)->index();
$table->string('subject_type', 100)->nullable();
$table->unsignedBigInteger('subject_id')->nullable();
$table->foreignId('target_user_id')->nullable()->constrained('users')->nullOnDelete();
$table->unsignedBigInteger('project_id')->nullable();
$table->json('old_values')->nullable();
$table->json('new_values')->nullable();
$table->text('justification')->nullable();
$table->string('ip_address', 45)->nullable();
$table->text('user_agent')->nullable();
$table->timestamp('created_at')->nullable()->index();
$table->index(['subject_type', 'subject_id']);
$table->index('project_id');
});
}
public function down(): void
{
Schema::dropIfExists('audit_logs');
}
};

View File

@@ -0,0 +1,76 @@
<?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('transcription_projects', function (Blueprint $table) {
$table->id();
$table->uuid('uuid')->unique();
$table->string('title');
$table->text('description')->nullable();
$table->foreignId('owner_user_id')->constrained('users')->restrictOnDelete();
$table->string('original_filename', 500);
$table->string('stored_audio_path', 1000);
$table->string('mime_type', 100);
$table->unsignedBigInteger('file_size');
$table->unsignedInteger('duration_seconds')->nullable();
$table->string('language', 10)->default('ms');
$table->enum('transcription_status', ['pending', 'processing', 'completed', 'failed'])->default('pending')->index();
$table->string('transcription_engine', 50)->nullable();
$table->longText('transcript_text')->nullable(); // encrypted via model cast
$table->decimal('transcript_confidence', 5, 4)->nullable();
$table->text('error_message')->nullable();
$table->timestamp('processed_at')->nullable();
$table->timestamps();
$table->softDeletes();
$table->index('owner_user_id');
});
Schema::create('project_collaborators', function (Blueprint $table) {
$table->id();
$table->foreignId('project_id')->constrained('transcription_projects')->cascadeOnDelete();
$table->foreignId('user_id')->constrained('users')->cascadeOnDelete();
$table->enum('role', ['editor', 'viewer'])->default('editor');
$table->foreignId('added_by')->constrained('users')->restrictOnDelete();
$table->timestamps();
$table->unique(['project_id', 'user_id']);
});
Schema::create('transcript_versions', function (Blueprint $table) {
$table->id();
$table->foreignId('project_id')->constrained('transcription_projects')->cascadeOnDelete();
$table->foreignId('edited_by')->constrained('users')->restrictOnDelete();
$table->unsignedInteger('version_number');
$table->longText('old_text')->nullable();
$table->longText('new_text');
$table->string('change_summary', 500)->nullable();
$table->timestamp('created_at')->nullable();
$table->index(['project_id', 'version_number']);
});
Schema::create('project_comments', function (Blueprint $table) {
$table->id();
$table->foreignId('project_id')->constrained('transcription_projects')->cascadeOnDelete();
$table->foreignId('user_id')->constrained('users')->restrictOnDelete();
$table->text('message');
$table->timestamps();
$table->softDeletes();
});
}
public function down(): void
{
Schema::dropIfExists('project_comments');
Schema::dropIfExists('transcript_versions');
Schema::dropIfExists('project_collaborators');
Schema::dropIfExists('transcription_projects');
}
};