firefly-iii/database/migrations/2014_06_27_163817_create_components_table.php
2015-02-11 07:35:10 +01:00

52 lines
1.1 KiB
PHP

<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
/**
* @SuppressWarnings(PHPMD.ShortMethodName)
*
* Class CreateComponentsTable
*
*/
class CreateComponentsTable extends Migration
{
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('components');
}
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create(
'components', function (Blueprint $table) {
$table->increments('id');
$table->timestamps();
$table->softDeletes();
$table->string('name', 50);
$table->integer('user_id')->unsigned();
$table->string('class', 20);
// connect components to users
$table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
// for a user, the component type & name must be unique.
$table->unique(['user_id', 'class', 'name']);
}
);
}
}