Complete Part 8

This commit is contained in:
Thuan Bui
2025-05-10 11:54:10 +09:00
parent c4288c40b9
commit 3b343ba25a
8 changed files with 915 additions and 78 deletions
@@ -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('media', function (Blueprint $table) {
$table->id();
$table->morphs('model');
$table->uuid()->nullable()->unique();
$table->string('collection_name');
$table->string('name');
$table->string('file_name');
$table->string('mime_type')->nullable();
$table->string('disk');
$table->string('conversions_disk')->nullable();
$table->unsignedBigInteger('size');
$table->json('manipulations');
$table->json('custom_properties');
$table->json('generated_conversions');
$table->json('responsive_images');
$table->unsignedInteger('order_column')->nullable()->index();
$table->nullableTimestamps();
});
}
};
@@ -0,0 +1,38 @@
<?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('uploads', function (Blueprint $table) {
// Check if the columns exist before trying to drop them (optional, but good practice)
if (Schema::hasColumn('uploads', 'filename')) {
$table->dropColumn('filename');
}
if (Schema::hasColumn('uploads', 'thumbnail')) {
$table->dropColumn('thumbnail');
}
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('uploads', function (Blueprint $table) {
// Re-add the columns if rolling back.
// Adjust the type if they were different (e.g., text)
// Making them nullable as they might not have data if rolled back after new entries.
$table->string('filename')->nullable();
$table->string('thumbnail')->nullable();
});
}
};