2026_10_26_100000_create_announcements.php 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. <?php
  2. use Illuminate\Database\Migrations\Migration;
  3. use Illuminate\Database\Schema\Blueprint;
  4. use Illuminate\Support\Facades\Schema;
  5. return new class extends Migration {
  6. public function up(): void
  7. {
  8. Schema::create('announcements', function (Blueprint $table) {
  9. $table->engine = 'InnoDB';
  10. $table->id();
  11. $table->string('category', 16);
  12. $table->json('publish_platforms');
  13. $table->string('display_frequency', 24)->default('daily_first_login');
  14. $table->dateTime('publish_at');
  15. $table->dateTime('end_at')->nullable();
  16. $table->unsignedTinyInteger('status')->default(1);
  17. $table->string('click_type', 16)->default('none');
  18. $table->string('link', 2048)->nullable();
  19. $table->unsignedBigInteger('activity_id')->nullable();
  20. $table->unsignedBigInteger('sender_id');
  21. $table->string('sender_name', 100);
  22. $table->timestamps();
  23. $table->index(['status', 'publish_at'], 'announcement_publication');
  24. $table->index('end_at');
  25. });
  26. Schema::create('announcement_translations', function (Blueprint $table) {
  27. $table->engine = 'InnoDB'; $table->id(); $table->unsignedBigInteger('announcement_id');
  28. $table->string('language', 8); $table->string('title', 200); $table->mediumText('content');
  29. $table->unique(['announcement_id', 'language'], 'announcement_translation');
  30. });
  31. }
  32. public function down(): void
  33. {
  34. Schema::dropIfExists('announcement_translations'); Schema::dropIfExists('announcements');
  35. }
  36. };