simplified tables and added indexes

pull/26/head
Ondřej Hruška 6 years ago
parent be3164e997
commit 34e4ed5d9b
Signed by: MightyPork
GPG Key ID: 2C5FD5035250423D
  1. 0
      database/-postponed/2018_07_08_202724_create_table_comments_table.php
  2. 0
      database/-postponed/2018_07_08_203424_create_user_follows_table.php
  3. 0
      database/-postponed/2018_07_08_203801_create_discussion_follows_table.php
  4. 0
      database/-postponed/2018_07_08_204223_create_table_favourites_table.php
  5. 68
      database/migrations/2018_07_08_193638_create_data_tables_table.php
  6. 2
      database/migrations/2018_07_08_204449_create_oauth_identities_table.php

@ -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');
}
}

@ -24,6 +24,8 @@ class CreateOauthIdentitiesTable extends Migration
$table->foreign('user_id')
->references('id')->on('users')
->onDelete('cascade');
$table->index('user_id');
});
}

Loading…
Cancel
Save