Просмотр файла database/migrations/2018_04_20_180010_create_comments_table.php

Размер файла: 1Kb
  1. <?php
  2.  
  3. declare(strict_types=1);
  4.  
  5. use Illuminate\Database\Migrations\Migration;
  6. use Illuminate\Database\Schema\Blueprint;
  7. use Illuminate\Support\Facades\Schema;
  8.  
  9. final class CreateCommentsTable extends Migration
  10. {
  11. /**
  12. * Migrate Up.
  13. */
  14. public function up(): void
  15. {
  16. if (! Schema::hasTable('comments')) {
  17. Schema::create('comments', function (Blueprint $table) {
  18. $table->increments('id');
  19. $table->integer('user_id');
  20. $table->string('relate_type', 10);
  21. $table->integer('relate_id');
  22. $table->text('text');
  23. $table->ipAddress('ip');
  24. $table->string('brow', 25);
  25. $table->integer('created_at');
  26.  
  27. $table->index('created_at');
  28. $table->index(['relate_type', 'relate_id']);
  29. });
  30. }
  31. }
  32.  
  33. /**
  34. * Migrate Down.
  35. */
  36. public function down(): void
  37. {
  38. Schema::dropIfExists('comments');
  39. }
  40. }