Files
BarangaySystem/database/migrations/2025_07_14_062954_create_files_table.php
2026-06-06 18:43:00 +08:00

90 lines
2.7 KiB
PHP

<?php
use Hyperf\Database\Schema\Schema;
use Hyperf\Database\Schema\Blueprint;
use Hyperf\Database\Migrations\Migration;
return new class extends Migration {
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('file_content', function (Blueprint $table) {
$table->id();
$table->string('hashkey', 300)->unique();
$table->string('filehash', 300)->unique();
$table->string('titlename', 2000)->default('');
$table->text('description')->nullable();
$table->unsignedBigInteger('size_in_bytes')->default(0);
$table->json('details')->nullable();
// $table->binary('content');
if (Schema::getConnection()->getDriverName() === 'pgsql') {
$table->binary('content');
} else {
$table->longText('content');
}
$table->text('mimetype')->nullable();
$table->text('filelocation')->nullable();
// $table->bigInteger('created_by')->constrained('users', 'id')->nullable();
// $table->bigInteger('updated_by')->constrained('users', 'id')->nullable();
$table->foreignId('created_by')
->nullable()
->constrained('users', 'id')
->nullOnDelete();
$table->foreignId('updated_by')
->nullable()
->constrained('users', 'id')
->nullOnDelete();
$table->timestamps();
});
Schema::create('file_list', function (Blueprint $table) {
$table->id();
$table->json('useruid_access_list')->nullable();
$table->string('hashkey', 300)->unique();
$table->foreignId('contentuid')
->constrained('file_content', 'id')
->cascadeOnDelete();
$table->string('title', 300)->default('');
$table->string('filename', 300)->default('');
$table->text('description')->nullable();
$table->string('tags', 600)->default('');
$table->integer('hidden')->default(0);
$table->text('categories')->nullable();
$table->foreignId('created_by')
->nullable()
->constrained('users', 'id')
->nullOnDelete();
$table->foreignId('updated_by')
->nullable()
->constrained('users', 'id')
->nullOnDelete();
$table->json('details')->nullable();
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('file_content');
Schema::dropIfExists('file_list');
}
};