Просмотр файла database/migrations/20180420180034_create_photos_table.php

Размер файла: 998B
  1. <?php
  2.  
  3. declare(strict_types=1);
  4.  
  5. use App\Migrations\Migration;
  6. use Illuminate\Database\Schema\Blueprint;
  7.  
  8. final class CreatePhotosTable extends Migration
  9. {
  10. /**
  11. * Migrate Up.
  12. */
  13. public function up(): void
  14. {
  15. if (! $this->schema->hasTable('photos')) {
  16. $this->schema->create('photos', function (Blueprint $table) {
  17. $table->increments('id');
  18. $table->integer('user_id');
  19. $table->string('title', 50);
  20. $table->text('text');
  21. $table->integer('rating')->default(0);
  22. $table->boolean('closed')->default(false);
  23. $table->integer('count_comments')->default(0);
  24. $table->integer('created_at');
  25.  
  26. $table->index('user_id');
  27. $table->index('created_at');
  28. });
  29. }
  30. }
  31.  
  32. /**
  33. * Migrate Down.
  34. */
  35. public function down(): void
  36. {
  37. $this->schema->dropIfExists('photos');
  38. }
  39. }