|
| 1 | +<?php |
| 2 | + |
| 3 | +use Illuminate\Database\Migrations\Migration; |
| 4 | +use Illuminate\Database\Schema\Blueprint; |
| 5 | +use Illuminate\Support\Facades\Schema; |
| 6 | + |
| 7 | +return new class extends Migration |
| 8 | +{ |
| 9 | + /** |
| 10 | + * Run the migrations. |
| 11 | + */ |
| 12 | + public function up(): void |
| 13 | + { |
| 14 | + Schema::create('category_translations', function (Blueprint $table) { |
| 15 | + $table->increments('id'); |
| 16 | + $table->unsignedBigInteger('category_id'); |
| 17 | + $table->string('locale')->index(); |
| 18 | + $table->string('title'); |
| 19 | + $table->string('status')->default('draft'); |
| 20 | + $table->string('slug'); |
| 21 | + $table->text('content')->nullable(); |
| 22 | + |
| 23 | + |
| 24 | + // Schedule fields |
| 25 | + $table->timestamp(column: 'to_publish_at')->nullable(); |
| 26 | + $table->timestamp('published_at')->nullable(); |
| 27 | + $table->timestamp('to_unpublish_at')->nullable(); |
| 28 | + $table->timestamp('unpublished_at')->nullable(); |
| 29 | + |
| 30 | + // Actor fields |
| 31 | + $table->nullableMorphs('published_by', 'cat_trans_pub_idx'); |
| 32 | + $table->nullableMorphs('unpublished_by', 'cat_trans_unpub_idx'); |
| 33 | + |
| 34 | + $table->foreignId('author_id')->nullable()->constrained('users')->nullOnDelete(); |
| 35 | + |
| 36 | + // Soft delete fields |
| 37 | + $table->softDeletes(); |
| 38 | + $table->nullableMorphs('deleted_by'); |
| 39 | + $table->timestamp('restored_at')->nullable(); |
| 40 | + $table->nullableMorphs('restored_by'); |
| 41 | + |
| 42 | + // Timestamps |
| 43 | + $table->timestamps(); |
| 44 | + |
| 45 | + $table->unique(['category_id', 'locale']); |
| 46 | + $table->foreign('category_id')->references('id')->on('categories')->onDelete('cascade'); |
| 47 | + }); |
| 48 | + } |
| 49 | + |
| 50 | + /** |
| 51 | + * Reverse the migrations. |
| 52 | + */ |
| 53 | + public function down(): void |
| 54 | + { |
| 55 | + Schema::dropIfExists('category_translations'); |
| 56 | + } |
| 57 | +}; |
0 commit comments