| Total Complexity | 2 |
| Total Lines | 41 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 7 | class CreateFilesTables extends Migration |
||
| 8 | { |
||
| 9 | /** |
||
| 10 | * Run the migrations. |
||
| 11 | * |
||
| 12 | * @return void |
||
| 13 | */ |
||
| 14 | public function up() |
||
| 15 | { |
||
| 16 | Schema::create('files', function (Blueprint $table) { |
||
| 17 | $table->increments('id')->unsigned(); |
||
| 18 | $table->timestamps(); |
||
| 19 | $table->softDeletes(); |
||
| 20 | $table->string('uuid'); |
||
| 21 | $table->string('filename')->nullable(); |
||
| 22 | $table->integer('size')->unsigned(); |
||
| 23 | }); |
||
| 24 | |||
| 25 | Schema::create('fileables', function (Blueprint $table) { |
||
| 26 | $table->increments('id'); |
||
| 27 | $table->timestamps(); |
||
| 28 | $table->softDeletes(); |
||
| 29 | $table->integer('file_id')->unsigned(); |
||
| 30 | $table->foreign('file_id', 'fk_files_file_id')->references('id')->on('files')->onDelete('cascade')->onUpdate('cascade'); |
||
| 31 | $table->integer('fileable_id')->nullable()->unsigned(); |
||
| 32 | $table->string('fileable_type')->nullable(); |
||
| 33 | $table->string('role')->nullable(); |
||
| 34 | $table->string('locale', 6)->index(); |
||
| 35 | $table->index(['fileable_type', 'fileable_id']); |
||
| 36 | }); |
||
| 37 | } |
||
| 38 | |||
| 39 | /** |
||
| 40 | * Reverse the migrations. |
||
| 41 | * |
||
| 42 | * @return void |
||
| 43 | */ |
||
| 44 | public function down() |
||
| 45 | { |
||
| 46 | Schema::dropIfExists('fileables'); |
||
| 47 | Schema::dropIfExists('files'); |
||
| 48 | } |
||
| 50 |