-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcreate_categories_table.php
40 lines (35 loc) · 1.36 KB
/
create_categories_table.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
<?php namespace Octoshop\Categories\Updates;
use Schema;
use Octoshop\Core\Updates\Migration;
use October\Rain\Database\Schema\Blueprint;
class CreateCategoriesTable extends Migration
{
public function up()
{
Schema::create('octoshop_categories', function (Blueprint $table) {
$table->engine = 'InnoDB';
$table->increments('id');
$table->string('name')->index();
$table->string('slug')->index()->unique();
$table->text('description')->nullable();
$table->boolean('is_enabled')->default(false);
$table->boolean('is_visible')->default(true);
$table->integer('parent_id')->unsigned()->index()->nullable();
$table->integer('nest_left')->default(0);
$table->integer('nest_right')->default(0);
$table->integer('nest_depth')->default(0);
$table->timestamps();
});
Schema::create('octoshop_product_categories', function (Blueprint $table) {
$table->integer('product_id')->unsigned();
$table->integer('category_id')->unsigned();
$table->timestamps();
$table->primary(['product_id', 'category_id']);
});
}
public function down()
{
Schema::dropIfExists('octoshop_categories');
Schema::dropIfExists('octoshop_product_categories');
}
}