88 lines
2.4 KiB
PHP
88 lines
2.4 KiB
PHP
<?php
|
|
|
|
use Illuminate\Database\Migrations\Migration;
|
|
use Illuminate\Database\Capsule\Manager as Capsule;
|
|
|
|
class InitializeDatabase extends Migration
|
|
{
|
|
/**
|
|
* Run the migrations.
|
|
*
|
|
* @return void
|
|
*/
|
|
public function up()
|
|
{
|
|
$builder = Capsule::schema();
|
|
|
|
$builder->create(
|
|
'dimensions',
|
|
function ($table) {
|
|
$table->increments('id');
|
|
$table->string('name')->unique();
|
|
$table->string('short')->unique();
|
|
}
|
|
);
|
|
|
|
$builder->create(
|
|
'groups',
|
|
function ($table) {
|
|
$table->increments('id');
|
|
$table->string('name')->unique();
|
|
}
|
|
);
|
|
|
|
$builder->create(
|
|
'articles',
|
|
function ($table) {
|
|
$table->increments('id');
|
|
$table->string('name')->unique();
|
|
$table->string('short')->unique();
|
|
$table->unsignedInteger('group_id');
|
|
$table->foreign('group_id')->references('id')->on('groups');
|
|
$table->float('content_size');
|
|
$table->float('portion_size');
|
|
$table->float('portion_price');
|
|
$table->unsignedInteger('content_dimension');
|
|
$table->foreign('content_dimension')->references('id')->on('dimensions');
|
|
$table->unsignedInteger('portion_dimension');
|
|
$table->foreign('portion_dimension')->references('id')->on('dimensions');
|
|
|
|
$table->timestamps();
|
|
}
|
|
);
|
|
|
|
$builder->create(
|
|
'sets',
|
|
function ($table) {
|
|
$table->increments('id');
|
|
$table->string('name')->unique();
|
|
|
|
$table->timestamps();
|
|
}
|
|
);
|
|
|
|
$builder->create(
|
|
'set_article',
|
|
function ($table) {
|
|
$table->increments('id');
|
|
$table->unsignedInteger('order');
|
|
$table->unsignedInteger('set_id');
|
|
$table->foreign('set_id')->references('id')->on('sets');
|
|
$table->unsignedInteger('article_id');
|
|
$table->foreign('article_id')->references('id')->on('articles');
|
|
|
|
$table->timestamps();
|
|
}
|
|
);
|
|
}
|
|
|
|
/**
|
|
* Reverse the migrations.
|
|
*
|
|
* @return void
|
|
*/
|
|
public function down()
|
|
{
|
|
}
|
|
}
|