2020_05_30_203523_create_base_attachments_table.php 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <?php
  2. use Illuminate\Support\Facades\Schema;
  3. use Illuminate\Database\Schema\Blueprint;
  4. use Illuminate\Database\Migrations\Migration;
  5. class CreateBaseAttachmentsTable extends Migration
  6. {
  7. /**
  8. * Run the migrations.
  9. *
  10. * @return void
  11. */
  12. public function up()
  13. {
  14. Schema::create('base_attachments', function (Blueprint $table) {
  15. $table->increments('id');
  16. $table->string('name', 255)->comment('附件名称');
  17. $table->string('md5', 50)->comment('md5码');
  18. $table->string('path', 1024)->comment('附件路径');
  19. $table->string('url', 1024)->comment('附件url');
  20. $table->string('class', 255)->default('未分类')->comment('分类');
  21. $table->unsignedBigInteger('size')->nullable();
  22. $table->string('file_type', 100)->nullable();
  23. $table->unsignedBigInteger('download')->default(0);
  24. $table->string('klass', 50)->nullable()->comment('关联模型');
  25. $table->unsignedInteger('objid')->nullable()->comment('关联id');
  26. $table->timestamps();
  27. $table->softDeletes();
  28. $table->index('md5', 'idx_md5');
  29. $table->index(['klass', 'objid'], 'idx_klass_objid');
  30. });
  31. }
  32. /**
  33. * Reverse the migrations.
  34. *
  35. * @return void
  36. */
  37. public function down()
  38. {
  39. Schema::dropIfExists('base_attachments');
  40. }
  41. }