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.
45 lines
1.4 KiB
45 lines
1.4 KiB
<?php
|
|
|
|
use Illuminate\Support\Facades\Schema;
|
|
use Illuminate\Database\Schema\Blueprint;
|
|
use Illuminate\Database\Migrations\Migration;
|
|
|
|
class CreateChangesetsTable extends Migration
|
|
{
|
|
/**
|
|
* Run the migrations.
|
|
*
|
|
* @return void
|
|
*/
|
|
public function up()
|
|
{
|
|
Schema::create('changesets', function (Blueprint $table) {
|
|
$table->increments('id');
|
|
$table->timestamps();
|
|
$table->unsignedInteger('data_table_id')->index();
|
|
$table->unsignedInteger('target_revision');
|
|
$table->text('message');
|
|
$table->boolean('applied');
|
|
$table->unsignedInteger('author_id')->index()->nullable();
|
|
$table->jsonb('patch'); // incremental changeset including original row values so that it can be reversed
|
|
|
|
$table->foreign('data_table_id')->references('id')->on('data_tables')
|
|
->onDelete('cascade');
|
|
|
|
// Deleting a user should not delete their applied patches, as that would break history.
|
|
// We set the author to null and unmerged patches may be cleaned manually or by a separate query.
|
|
$table->foreign('author_id')->references('id')->on('users')
|
|
->onDelete('set null');
|
|
});
|
|
}
|
|
|
|
/**
|
|
* Reverse the migrations.
|
|
*
|
|
* @return void
|
|
*/
|
|
public function down()
|
|
{
|
|
Schema::dropIfExists('changesets');
|
|
}
|
|
}
|
|
|