2026_05_07_091034_create_leads_table.php 1.1 KB

1234567891011121314151617181920212223242526272829303132333435
  1. <?php
  2. /*
  3. * Миграция: таблица leads — заявки с форм сайта.
  4. * Создана: 2026-05-07
  5. * Поля:
  6. * form_id — ID формы (web_forms), FK с каскадным удалением
  7. * data — JSON-объект с данными заявки {field_name: value, ...}
  8. * ip — IP-адрес отправителя
  9. * read_at — когда менеджер просмотрел заявку (null = новая)
  10. */
  11. use Illuminate\Database\Migrations\Migration;
  12. use Illuminate\Database\Schema\Blueprint;
  13. use Illuminate\Support\Facades\Schema;
  14. return new class extends Migration
  15. {
  16. public function up(): void
  17. {
  18. Schema::create('leads', function (Blueprint $table) {
  19. $table->id();
  20. $table->foreignId('form_id')->constrained('web_forms')->cascadeOnDelete();
  21. $table->json('data');
  22. $table->string('ip', 45)->nullable();
  23. $table->timestamp('read_at')->nullable();
  24. $table->timestamps();
  25. });
  26. }
  27. public function down(): void
  28. {
  29. Schema::dropIfExists('leads');
  30. }
  31. };