2018-12-03 12:59:22 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
use Illuminate\Support\Facades\Schema;
|
|
|
|
use Illuminate\Database\Schema\Blueprint;
|
|
|
|
use Illuminate\Database\Migrations\Migration;
|
|
|
|
|
|
|
|
class InitDatabase extends Migration
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* Run the migrations.
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function up()
|
|
|
|
{
|
|
|
|
$this->down();
|
|
|
|
|
|
|
|
Schema::create('modes', function (Blueprint $table) {
|
2018-12-10 11:59:02 +00:00
|
|
|
$table->timestamps();
|
|
|
|
$table->integer('id')->autoIncrement();
|
|
|
|
$table->string('name',16);
|
|
|
|
$table->string('note',255);
|
2018-12-03 12:59:22 +00:00
|
|
|
|
2018-12-10 11:59:02 +00:00
|
|
|
$table->unique(['name']);
|
2018-12-03 12:59:22 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
Schema::create('cugs', function (Blueprint $table) {
|
2018-12-10 11:59:02 +00:00
|
|
|
$table->timestamps();
|
|
|
|
$table->integer('id');
|
|
|
|
$table->string('name',16);
|
|
|
|
$table->string('note',255);
|
|
|
|
$table->integer('parent_id')->nullable();
|
2018-12-03 12:59:22 +00:00
|
|
|
|
2018-12-10 11:59:02 +00:00
|
|
|
$table->primary('id');
|
|
|
|
$table->foreign('parent_id')->references('id')->on('cugs');
|
|
|
|
$table->unique(['name']);
|
2018-12-03 12:59:22 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
Schema::create('frames', function (Blueprint $table) {
|
2018-12-10 11:59:02 +00:00
|
|
|
$table->timestamps();
|
|
|
|
$table->integer('id')->autoIncrement();
|
|
|
|
$table->integer('frame');
|
|
|
|
$table->char('index',1);
|
|
|
|
$table->integer('mode_id');
|
|
|
|
$table->char('type',2);
|
|
|
|
$table->smallInteger('cost')->default(0);
|
|
|
|
$table->integer('cug_id')->default(0);
|
|
|
|
$table->boolean('public')->default(FALSE);
|
|
|
|
$table->binary('content');
|
|
|
|
$table->string('note',255)->nullable();
|
2018-12-03 12:59:22 +00:00
|
|
|
|
2018-12-10 11:59:02 +00:00
|
|
|
//$table->unique(['frame','index','mode_id']); // Not needed since we have timewarp
|
2018-12-03 12:59:22 +00:00
|
|
|
|
2018-12-10 11:59:02 +00:00
|
|
|
$table->foreign('mode_id')->references('id')->on('modes');
|
|
|
|
$table->foreign('cug_id')->references('id')->on('cugs');
|
2018-12-03 12:59:22 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
Schema::create('routes', function (Blueprint $table) {
|
2018-12-10 11:59:02 +00:00
|
|
|
$table->integer('id')->autoIncrement();
|
|
|
|
$table->char('key',1);
|
|
|
|
$table->integer('route');
|
2018-12-03 12:59:22 +00:00
|
|
|
|
2018-12-10 11:59:02 +00:00
|
|
|
$table->foreign('route')->references('id')->on('frames');
|
2018-12-03 12:59:22 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Reverse the migrations.
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function down()
|
|
|
|
{
|
|
|
|
Schema::dropIfExists('routes');
|
|
|
|
Schema::dropIfExists('frames');
|
|
|
|
Schema::dropIfExists('cugs');
|
|
|
|
Schema::dropIfExists('modes');
|
|
|
|
}
|
2018-12-10 11:59:02 +00:00
|
|
|
}
|