|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
use Illuminate\Database\Migrations\Migration; |
|
4
|
|
|
use Illuminate\Database\Schema\Blueprint; |
|
5
|
|
|
use Illuminate\Support\Facades\Schema; |
|
6
|
|
|
|
|
7
|
|
|
class CreateMediasTables extends Migration |
|
8
|
|
|
{ |
|
9
|
|
|
/** |
|
10
|
|
|
* Run the migrations. |
|
11
|
|
|
* |
|
12
|
|
|
* @return void |
|
13
|
|
|
*/ |
|
14
|
|
|
public function up() |
|
15
|
|
|
{ |
|
16
|
|
|
Schema::create('medias', function (Blueprint $table) { |
|
17
|
|
|
$table->increments('id')->unsigned(); |
|
18
|
|
|
$table->timestamps(); |
|
19
|
|
|
$table->softDeletes(); |
|
20
|
|
|
$table->string('uuid'); |
|
21
|
|
|
$table->string('alt_text'); |
|
22
|
|
|
$table->integer('width')->unsigned(); |
|
23
|
|
|
$table->integer('height')->unsigned(); |
|
24
|
|
|
$table->string('caption')->nullable(); |
|
25
|
|
|
$table->string('filename')->nullable(); |
|
26
|
|
|
}); |
|
27
|
|
|
|
|
28
|
|
|
Schema::create('mediables', function (Blueprint $table) { |
|
29
|
|
|
$table->increments('id'); |
|
30
|
|
|
$table->timestamps(); |
|
31
|
|
|
$table->softDeletes(); |
|
32
|
|
|
$table->integer('mediable_id')->nullable()->unsigned(); |
|
33
|
|
|
$table->string('mediable_type')->nullable(); |
|
34
|
|
|
$table->integer('media_id')->unsigned(); |
|
35
|
|
|
$table->integer('crop_x')->nullable(); |
|
36
|
|
|
$table->integer('crop_y')->nullable(); |
|
37
|
|
|
$table->integer('crop_w')->nullable(); |
|
38
|
|
|
$table->integer('crop_h')->nullable(); |
|
39
|
|
|
$table->string('role')->nullable(); |
|
40
|
|
|
$table->string('crop')->nullable(); |
|
41
|
|
|
$table->text('lqip_data')->nullable(); |
|
42
|
|
|
$table->string('ratio')->nullable(); |
|
43
|
|
|
$table->json('metadatas'); |
|
44
|
|
|
$table->foreign('media_id', 'fk_mediables_media_id')->references('id')->on('medias')->onDelete('cascade')->onUpdate('cascade'); |
|
45
|
|
|
$table->index(['mediable_type', 'mediable_id']); |
|
46
|
|
|
}); |
|
47
|
|
|
} |
|
48
|
|
|
|
|
49
|
|
|
/** |
|
50
|
|
|
* Reverse the migrations. |
|
51
|
|
|
* |
|
52
|
|
|
* @return void |
|
53
|
|
|
*/ |
|
54
|
|
|
public function down() |
|
55
|
|
|
{ |
|
56
|
|
|
Schema::dropIfExists('mediables'); |
|
57
|
|
|
Schema::dropIfExists('medias'); |
|
58
|
|
|
} |
|
59
|
|
|
} |
|
60
|
|
|
|