new ataxchments preview code
This commit is contained in:
+64
@@ -0,0 +1,64 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Add optional attachment metadata used by previews, source viewing and audit trails.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('helpdesk_attachments', static function (Blueprint $table): void {
|
||||
if (! Schema::hasColumn('helpdesk_attachments', 'extension')) {
|
||||
$table->string('extension', 32)->nullable()->after('original_name')->index();
|
||||
}
|
||||
|
||||
if (! Schema::hasColumn('helpdesk_attachments', 'category')) {
|
||||
$table->string('category', 32)->nullable()->after('extension')->index();
|
||||
}
|
||||
|
||||
if (! Schema::hasColumn('helpdesk_attachments', 'checksum_sha256')) {
|
||||
$table->string('checksum_sha256', 64)->nullable()->after('size')->index();
|
||||
}
|
||||
|
||||
if (! Schema::hasColumn('helpdesk_attachments', 'download_count')) {
|
||||
$table->unsignedInteger('download_count')->default(0)->after('checksum_sha256');
|
||||
}
|
||||
|
||||
if (! Schema::hasColumn('helpdesk_attachments', 'last_downloaded_at')) {
|
||||
$table->timestamp('last_downloaded_at')->nullable()->after('download_count');
|
||||
}
|
||||
|
||||
if (! Schema::hasColumn('helpdesk_attachments', 'deleted_at')) {
|
||||
$table->timestamp('deleted_at')->nullable()->after('last_downloaded_at')->index();
|
||||
}
|
||||
|
||||
if (! Schema::hasColumn('helpdesk_attachments', 'deleted_by')) {
|
||||
$table->foreignId('deleted_by')->nullable()->after('deleted_at')->constrained('users')->nullOnDelete();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove attachment experience metadata.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('helpdesk_attachments', static function (Blueprint $table): void {
|
||||
if (Schema::hasColumn('helpdesk_attachments', 'deleted_by')) {
|
||||
$table->dropConstrainedForeignId('deleted_by');
|
||||
}
|
||||
|
||||
foreach (['deleted_at', 'last_downloaded_at', 'download_count', 'checksum_sha256', 'category', 'extension'] as $column) {
|
||||
if (Schema::hasColumn('helpdesk_attachments', $column)) {
|
||||
$table->dropColumn($column);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user