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.
49 lines
1.6 KiB
49 lines
1.6 KiB
<?php
|
|
|
|
use Illuminate\Support\Facades\Schema;
|
|
use Illuminate\Database\Schema\Blueprint;
|
|
use Illuminate\Database\Migrations\Migration;
|
|
|
|
class CreateTablesTable extends Migration
|
|
{
|
|
/**
|
|
* Run the migrations.
|
|
*
|
|
* @return void
|
|
*/
|
|
public function up()
|
|
{
|
|
Schema::create('tables', function (Blueprint $table) {
|
|
$table->increments('id');
|
|
$table->timestamps();
|
|
$table->unsignedInteger('owner_id');
|
|
$table->unsignedInteger('ancestor_id')->index()->nullable();
|
|
$table->unsignedInteger('revision_id')->index(); // active revision
|
|
$table->string('name')->index(); // indexable
|
|
$table->string('title')->index(); // indexable
|
|
$table->text('description')->nullable();
|
|
$table->text('license')->nullable();
|
|
$table->text('origin')->nullable();
|
|
|
|
$table->foreign('owner_id')->references('id')->on('users')
|
|
->onDelete('restrict'); // user deleting their account deletes owned tables
|
|
// we block it with RESTRICT to ensure tables are deleted manually
|
|
|
|
$table->foreign('revision_id')->references('id')->on('revisions')
|
|
->onDelete('restrict');
|
|
|
|
$table->foreign('ancestor_id')->references('id')->on('tables')
|
|
->onDelete('set null'); // fork parent deletion must NOT delete child tables
|
|
});
|
|
}
|
|
|
|
/**
|
|
* Reverse the migrations.
|
|
*
|
|
* @return void
|
|
*/
|
|
public function down()
|
|
{
|
|
Schema::dropIfExists('tables');
|
|
}
|
|
}
|
|
|