This repository has been archived on 2024-04-08. You can view files and clone it, but cannot push or open issues or pull requests.
vbbs/database/migrations/2018_12_03_104758_init_data...

74 lines
2.0 KiB
PHP

<?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) {
$table->timestamps();
$table->integer('id')->autoIncrement()->index();
$table->string('name',16);
$table->string('note',255);
$table->unique(['name']);
});
Schema::create('cugs', function (Blueprint $table) {
$table->timestamps();
$table->integer('id')->index()->unique();
$table->string('name', 16);
$table->string('note', 255);
$table->integer('parent_id')->nullable()->index();
});
Schema::table('cugs', function (Blueprint $table) {
$table->foreign('parent_id')->references('id')->on('cugs');
$table->unique(['name']);
});
Schema::create('frames', function (Blueprint $table) {
$table->timestamps();
$table->integer('id')->autoIncrement()->index();
$table->integer('frame');
$table->char('index', 1);
$table->integer('mode_id')->index();
$table->char('type', 2);
$table->smallInteger('cost')->default(0);
$table->integer('cug_id')->default(0)->index();
$table->boolean('public')->default(FALSE);
$table->binary('content');
$table->string('note', 255)->nullable();
//$table->unique(['frame','index','mode_id']); // Not needed since we have timewarp
});
Schema::table('frames', function (Blueprint $table) {
$table->foreign('mode_id')->references('id')->on('modes');
$table->foreign('cug_id')->references('id')->on('cugs');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('routes');
Schema::dropIfExists('frames');
Schema::dropIfExists('cugs');
Schema::dropIfExists('modes');
}
}