Просмотр файла database/migrations/20180420180017_create_files_table.php

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