2026_05_07_194433_create_page_visits_table.php 771 B

1234567891011121314151617181920212223242526272829
  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. {
  7. /**
  8. * Run the migrations.
  9. */
  10. public function up(): void
  11. {
  12. Schema::create('page_visits', function (Blueprint $table) {
  13. // Агрегированный счётчик посещений по дням: один row = одна дата
  14. $table->date('date')->primary();
  15. $table->unsignedInteger('views')->default(0);
  16. $table->unsignedInteger('unique_ips')->default(0);
  17. });
  18. }
  19. /**
  20. * Reverse the migrations.
  21. */
  22. public function down(): void
  23. {
  24. Schema::dropIfExists('page_visits');
  25. }
  26. };