Просмотр файла database/migrations/20180420180047_create_topics_table.php

Размер файла: 1.63Kb
  1. <?php
  2.  
  3. declare(strict_types=1);
  4.  
  5. use App\Migrations\Migration;
  6. use Illuminate\Database\Schema\Blueprint;
  7.  
  8. final class CreateTopicsTable extends Migration
  9. {
  10. /**
  11. * Migrate Up.
  12. */
  13. public function up(): void
  14. {
  15. if (! $this->schema->hasTable('topics')) {
  16. $this->schema->create('topics', function (Blueprint $table) {
  17. $table->increments('id');
  18. $table->integer('forum_id');
  19. $table->string('title', 50);
  20. $table->integer('user_id');
  21. $table->boolean('closed')->default(false);
  22. $table->boolean('locked')->default(false);
  23. $table->string('moderators')->nullable();
  24. $table->string('note')->nullable();
  25. $table->integer('count_posts');
  26. $table->integer('visits')->default(0);
  27. $table->integer('last_post_id')->nullable();
  28. $table->integer('close_user_id')->nullable();
  29. $table->integer('updated_at')->nullable();
  30. $table->integer('created_at');
  31.  
  32. $table->index(['count_posts', 'updated_at']);
  33. $table->index(['user_id', 'updated_at']);
  34. $table->index(['forum_id', 'locked', 'updated_at']);
  35. $table->index('updated_at');
  36. });
  37.  
  38. if (config('database.default') === 'mysql') {
  39. $this->db->getConnection()->statement('CREATE FULLTEXT INDEX text ON topics(title);');
  40. }
  41. }
  42. }
  43.  
  44. /**
  45. * Migrate Down.
  46. */
  47. public function down(): void
  48. {
  49. $this->schema->dropIfExists('topics');
  50. }
  51. }