datatable.directory codebase
https://datatable.directory/
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
52 lines
1.7 KiB
52 lines
1.7 KiB
6 years ago
|
<?php
|
||
|
|
||
|
use Illuminate\Support\Facades\Schema;
|
||
|
use Illuminate\Database\Schema\Blueprint;
|
||
|
use Illuminate\Database\Migrations\Migration;
|
||
|
|
||
|
class CreateProposalsTable extends Migration
|
||
|
{
|
||
|
/**
|
||
|
* Run the migrations.
|
||
|
*
|
||
|
* @return void
|
||
|
*/
|
||
|
public function up()
|
||
|
{
|
||
|
Schema::create('proposals', function (Blueprint $table) {
|
||
|
$table->increments('id');
|
||
|
$table->timestamps();
|
||
|
|
||
|
// note that a revision may be shared by multiple tables, thus a proposal may also apply to different tables
|
||
|
|
||
|
$table->unsignedInteger('table_id')->index(); // table this proposal was written for
|
||
|
$table->unsignedInteger('revision_id')->index(); // parent revision (applying it to a different revisions may cause conflicts)
|
||
|
$table->unsignedInteger('author_id')->index();
|
||
|
|
||
|
$table->text('note');
|
||
|
|
||
|
// block the delete - we must first decrement Row refs and then the proposals manually
|
||
|
$table->foreign('revision_id')->references('id')->on('revisions')
|
||
|
->onDelete('restrict');
|
||
|
|
||
|
// deleting the table must NOT delete the proposals, as they may be applicable to forks sharing the revision
|
||
|
$table->foreign('table_id')->references('id')->on('tables')
|
||
|
->onDelete('set null');
|
||
|
|
||
|
// block the delete - we must first decrement Row refs and then the proposals manually
|
||
|
$table->foreign('author_id')->references('id')->on('users')
|
||
|
->onDelete('restrict');
|
||
|
});
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* Reverse the migrations.
|
||
|
*
|
||
|
* @return void
|
||
|
*/
|
||
|
public function down()
|
||
|
{
|
||
|
Schema::dropIfExists('proposals');
|
||
|
}
|
||
|
}
|