Просмотр файла database/migrations/20180420180015_create_downs_table.php

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