2015-02-05 21:41:00 -06:00
|
|
|
<?php
|
|
|
|
|
|
|
|
use Illuminate\Database\Migrations\Migration;
|
|
|
|
use Illuminate\Database\Schema\Blueprint;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @SuppressWarnings(PHPMD.ShortMethodName)
|
|
|
|
*
|
|
|
|
* Class CreatePreferencesTable
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
class CreatePreferencesTable extends Migration
|
|
|
|
{
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Reverse the migrations.
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function down()
|
|
|
|
{
|
|
|
|
Schema::drop('preferences');
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Run the migrations.
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function up()
|
|
|
|
{
|
|
|
|
Schema::create(
|
|
|
|
'preferences', function (Blueprint $table) {
|
2015-02-11 00:35:10 -06:00
|
|
|
$table->increments('id');
|
|
|
|
$table->timestamps();
|
|
|
|
$table->integer('user_id')->unsigned();
|
|
|
|
$table->string('name');
|
|
|
|
$table->text('data');
|
2015-02-05 21:41:00 -06:00
|
|
|
|
2015-02-11 00:35:10 -06:00
|
|
|
// connect preferences to users
|
|
|
|
$table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
|
2015-02-05 21:41:00 -06:00
|
|
|
|
2015-02-11 00:35:10 -06:00
|
|
|
// only one preference per name per user
|
|
|
|
$table->unique(['user_id', 'name']);
|
|
|
|
}
|
2015-02-05 21:41:00 -06:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|