|
|
|
@ -16,41 +16,51 @@ class CreateDataTablesTable extends Migration |
|
|
|
|
Schema::create('data_tables', function (Blueprint $table) { |
|
|
|
|
$table->increments('id'); |
|
|
|
|
$table->timestamps(); |
|
|
|
|
$table->unsignedInteger('owner_id'); |
|
|
|
|
$table->unsignedInteger('parent_data_table_id')->nullable(); |
|
|
|
|
$table->string('title'); |
|
|
|
|
$table->string('license'); |
|
|
|
|
$table->unsignedInteger('owner_id'); |
|
|
|
|
$table->unsignedInteger('forked_from_id')->nullable(); |
|
|
|
|
$table->unsignedInteger('revision'); // incremented with each applied changeset |
|
|
|
|
$table->string('title'); // indexable |
|
|
|
|
$table->string('keywords'); // indexable |
|
|
|
|
$table->text('description'); |
|
|
|
|
$table->string('license'); // license name (indexable) |
|
|
|
|
$table->mediumText('license_text'); // space for custom license text, if needed |
|
|
|
|
$table->longText('content'); |
|
|
|
|
|
|
|
|
|
$table->foreign('owner_id') |
|
|
|
|
->references('id')->on('users') |
|
|
|
|
->onDelete('cascade'); |
|
|
|
|
$table->foreign('owner_id') |
|
|
|
|
->references('id')->on('users') |
|
|
|
|
->onDelete('cascade'); |
|
|
|
|
|
|
|
|
|
$table->foreign('parent_data_table_id') |
|
|
|
|
->references('id')->on('data_tables') |
|
|
|
|
->onDelete('set null'); |
|
|
|
|
$table->foreign('forked_from_id') |
|
|
|
|
->references('id')->on('data_tables') |
|
|
|
|
->onDelete('set null'); |
|
|
|
|
|
|
|
|
|
$table->index('title'); // for text search |
|
|
|
|
$table->index('keywords'); // for text search |
|
|
|
|
$table->index('owner_id'); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
Schema::create('table_revisions', function (Blueprint $table) { |
|
|
|
|
$table->increments('id'); |
|
|
|
|
$table->timestamps(); |
|
|
|
|
$table->boolean('approved'); |
|
|
|
|
$table->unsignedInteger('data_table_id'); |
|
|
|
|
$table->unsignedInteger('parent_revision_id')->nullable(); |
|
|
|
|
$table->unsignedInteger('author_id')->nullable(); |
|
|
|
|
$table->longText('content'); |
|
|
|
|
Schema::create('changesets', function (Blueprint $table) { |
|
|
|
|
$table->increments('id'); |
|
|
|
|
$table->timestamps(); |
|
|
|
|
$table->unsignedInteger('data_table_id'); |
|
|
|
|
$table->unsignedInteger('target_revision'); |
|
|
|
|
$table->boolean('applied'); |
|
|
|
|
$table->unsignedInteger('author_id')->nullable(); |
|
|
|
|
$table->longText('content'); // incremental changeset including original row values so that it can be reversed |
|
|
|
|
|
|
|
|
|
$table->foreign('data_table_id') |
|
|
|
|
->references('id')->on('data_tables') |
|
|
|
|
->onDelete('cascade'); |
|
|
|
|
$table->foreign('data_table_id') |
|
|
|
|
->references('id')->on('data_tables') |
|
|
|
|
->onDelete('cascade'); |
|
|
|
|
|
|
|
|
|
$table->foreign('parent_revision_id') |
|
|
|
|
->references('id')->on('table_revisions') |
|
|
|
|
->onDelete('set null'); |
|
|
|
|
// 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'); |
|
|
|
|
|
|
|
|
|
$table->foreign('author_id') |
|
|
|
|
->references('id')->on('users') |
|
|
|
|
->onDelete('set null'); |
|
|
|
|
}); |
|
|
|
|
$table->index('author_id'); |
|
|
|
|
$table->index('data_table_id'); |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
@ -60,7 +70,7 @@ class CreateDataTablesTable extends Migration |
|
|
|
|
*/ |
|
|
|
|
public function down() |
|
|
|
|
{ |
|
|
|
|
Schema::dropIfExists('table_revisions'); |
|
|
|
|
Schema::dropIfExists('changesets'); |
|
|
|
|
Schema::dropIfExists('data_tables'); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|