updates to document handling and code editing features

This commit is contained in:
2025-12-03 23:27:08 +01:00
parent 88e526cf6c
commit 7b00887372
29 changed files with 20851 additions and 1114 deletions

View File

@@ -13,10 +13,23 @@ return new class extends Migration
{
Schema::create('documents', function (Blueprint $table) {
$table->id();
$table->string('code');
$table->string('name');
$table->enum('status', ['pending', 'in_review', 'approved', 'rejected'])->default('pending');
$table->foreignId('project_id')->constrained();
$table->foreignId('folder_id')->nullable()->constrained();
$table->string('area', 2)->nullable();
$table->string('discipline', 2)->nullable();
$table->string('document_type', 3)->nullable();
$table->string('version')->nullable()->default("0");
$table->string('revision')->nullable()->default("0");
$table->enum('status', [0, 1, 2, 3, 4])->default(0); //['pending', 'in_review', 'approved', 'rejected']
$table->string('issuer_id')->nullable();
$table->date('entry_date')->nullable()->default(now());
//$table->foreignId('current_version_id')->nullable()->constrained('document_versions');
$table->timestamps();
});

View File

@@ -15,11 +15,19 @@ return new class extends Migration
$table->id();
$table->foreignId('document_id')->constrained();
$table->string('file_path');
$table->string('hash');
$table->string('hash'); // SHA256 hash for integrity verification
$table->unsignedInteger('version')->default(1);
$table->unsignedInteger('review')->default(0);
$table->foreignId('user_id')->constrained();
$table->text('changes')->nullable();
$table->timestamps();
// Unique constraint to ensure one version per document
$table->unique(['document_id', 'version', 'review']);
// Index for faster queries
$table->index(['document_id', 'version']);
$table->index('hash');
});
}

View File

@@ -1,34 +0,0 @@
<?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('documents', function (Blueprint $table) {
$table->string('code')->before('name');
$table->string('revision')->nullable();
$table->string('version')->nullable();
$table->string('discipline')->nullable();
$table->string('document_type')->nullable();
$table->string('issuer')->nullable();
$table->date('entry_date')->nullable();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('documents', function (Blueprint $table) {
$table->dropColumn(['code', 'revision', 'version', 'discipline', 'document_type', 'issuer', 'entry_date']);
});
}
};