| 1 | <?php |
||
| 11 | class CreateMetaAttributesTable extends Migration |
||
| 12 | { |
||
| 13 | /** |
||
| 14 | * Meta attributes table name. |
||
| 15 | * |
||
| 16 | * @todo allow table name customization via config |
||
| 17 | * |
||
| 18 | * @var string |
||
| 19 | */ |
||
| 20 | protected $table = 'meta_attributes'; |
||
| 21 | |||
| 22 | /** |
||
| 23 | * Run the migrations. |
||
| 24 | * |
||
| 25 | * @return void |
||
| 26 | */ |
||
| 27 | public function up() |
||
| 28 | { |
||
| 29 | \Schema::create($this->table, function (Blueprint $table) { |
||
| 30 | $table->increments('meta_id'); |
||
| 31 | $table->string('meta_key'); |
||
| 32 | $table->longText('meta_value'); |
||
| 33 | $table->string('meta_type')->default('string'); |
||
| 34 | $table->morphs('metable'); |
||
| 35 | |||
| 36 | $table->index('meta_key'); |
||
| 37 | |||
| 38 | // Laravel doesn't handle index length, so we need raw statement for this one |
||
| 39 | \Schema::getConnection()->statement( |
||
| 40 | 'create index meta_attributes_index_value on meta_attributes (meta_key, meta_value(20))' |
||
| 41 | ); |
||
| 42 | }); |
||
| 43 | } |
||
| 44 | |||
| 45 | /** |
||
| 46 | * Reverse the migrations. |
||
| 47 | * |
||
| 48 | * @return void |
||
| 49 | */ |
||
| 50 | public function down() |
||
| 54 | } |
||
| 55 |