Просмотр файла database/migrations/20180420180036_create_posts_table.php

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