2025_10_02_071721_create_email_recipients_table.php 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. <?php
  2. use Illuminate\Database\Schema\Blueprint;
  3. use Illuminate\Support\Facades\Schema;
  4. use App\Database\Migrations\TenantMigration;
  5. return new class extends TenantMigration
  6. {
  7. /**
  8. * Run the migrations.
  9. *
  10. * @return void
  11. */
  12. public function up()
  13. {
  14. Schema::create('email_recipients', function (Blueprint $table) {
  15. $table->id();
  16. $table->unsignedBigInteger('email_template_id');
  17. $table->unsignedBigInteger('member_id');
  18. $table->string('email_address');
  19. $table->enum('status', ['pending', 'sent', 'failed', 'bounced'])->default('pending');
  20. $table->text('error_message')->nullable();
  21. $table->timestamp('sent_at')->nullable();
  22. $table->timestamps();
  23. $table->foreign('email_template_id')->references('id')->on('email_templates')->onDelete('cascade');
  24. $table->foreign('member_id')->references('id')->on('members');
  25. $table->unique(['email_template_id', 'member_id']);
  26. });
  27. }
  28. /**
  29. * Reverse the migrations.
  30. *
  31. * @return void
  32. */
  33. public function down()
  34. {
  35. Schema::dropIfExists('email_recipients');
  36. }
  37. };