more migrations

pull/26/head
Ondřej Hruška 6 years ago
parent 8fb5d30513
commit ce88fd3978
Signed by: MightyPork
GPG Key ID: 2C5FD5035250423D
  1. 41
      database/-postponed/2018_07_08_202724_create_table_comments_table.php
  2. 41
      database/-postponed/2018_07_08_203424_create_user_follows_table.php
  3. 42
      database/-postponed/2018_07_08_204223_create_table_favourites_table.php
  4. 1
      database/migrations/2018_07_08_193638_create_data_tables_table.php
  5. 5
      database/migrations/2018_07_08_193639_create_changesets_table.php
  6. 44
      database/migrations/2018_07_12_185431_create_comments_table.php
  7. 40
      database/migrations/2018_07_12_185840_create_favourites_table.php
  8. 14
      database/migrations/2018_07_12_190059_create_discussion_follows_table.php
  9. 39
      database/migrations/2018_07_12_190346_create_content_reports_table.php
  10. 41
      database/migrations/2018_07_12_190830_create_notifications_table.php

@ -1,41 +0,0 @@
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateTableCommentsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('table_comments', function (Blueprint $table) {
$table->increments('id');
$table->timestamps();
$table->unsignedInteger('data_table_id');
$table->unsignedInteger('author_id');
$table->foreign('data_table_id')
->references('id')->on('data_tables')
->onDelete('cascade');
$table->foreign('author_id')
->references('id')->on('users')
->onDelete('cascade');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('table_comments');
}
}

@ -1,41 +0,0 @@
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateUserFollowsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('user_follows', function (Blueprint $table) {
$table->increments('id');
$table->timestamps();
$table->unsignedInteger('user_id');
$table->unsignedInteger('target_user_id');
$table->foreign('user_id')
->references('id')->on('users')
->onDelete('cascade');
$table->foreign('target_user_id')
->references('id')->on('users')
->onDelete('cascade');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('user_follows');
}
}

@ -1,42 +0,0 @@
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateTableFavouritesTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('table_favourites', function (Blueprint $table) {
$table->increments('id');
$table->timestamps();
$table->unsignedInteger('user_id');
$table->unsignedInteger('data_table_id');
$table->foreign('user_id')
->references('id')->on('users')
->onDelete('cascade');
$table->foreign('data_table_id')
->references('id')->on('data_tables')
->onDelete('cascade');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('table_favourites');
}
}

@ -23,7 +23,6 @@ class CreateDataTablesTable extends Migration
$table->text('description');
$table->text('license');
$table->text('source_link');
$table->longText('content');
$table->foreign('owner_id')->references('id')->on('users')
->onDelete('cascade');

@ -15,12 +15,13 @@ class CreateChangesetsTable extends Migration
{
Schema::create('changesets', function (Blueprint $table) {
$table->increments('id');
$table->timestamp('created_at');
$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->longText('content'); // incremental changeset including original row values so that it can be reversed
$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');

@ -0,0 +1,44 @@
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateCommentsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('comments', function (Blueprint $table) {
$table->increments('id');
$table->timestamps();
$table->unsignedInteger('ancestor_id')->index()->nullable();
$table->unsignedInteger('author_id')->index();
$table->unsignedInteger('data_table_id')->index();
$table->text('message');
$table->foreign('data_table_id')->references('id')->on('data_tables')
->onDelete('cascade');
$table->foreign('author_id')->references('id')->on('users')
->onDelete('cascade');
$table->foreign('ancestor_id')->references('id')->on('comments')
->onDelete('set null');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('comments');
}
}

@ -0,0 +1,40 @@
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateFavouritesTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('favourites', function (Blueprint $table) {
$table->increments('id');
$table->timestamps();
$table->unsignedInteger('user_id');
$table->unsignedInteger('data_table_id');
$table->foreign('user_id')->references('id')->on('users')
->onDelete('cascade');
$table->foreign('data_table_id')->references('id')->on('data_tables')
->onDelete('cascade');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('favourites');
}
}

@ -16,16 +16,14 @@ class CreateDiscussionFollowsTable extends Migration
Schema::create('discussion_follows', function (Blueprint $table) {
$table->increments('id');
$table->timestamps();
$table->unsignedInteger('user_id');
$table->unsignedInteger('data_table_id');
$table->unsignedInteger('user_id');
$table->unsignedInteger('data_table_id');
$table->foreign('user_id')
->references('id')->on('users')
->onDelete('cascade');
$table->foreign('user_id')->references('id')->on('users')
->onDelete('cascade');
$table->foreign('data_table_id')
->references('id')->on('data_tables')
->onDelete('cascade');
$table->foreign('data_table_id')->references('id')->on('data_tables')
->onDelete('cascade');
});
}

@ -0,0 +1,39 @@
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateContentReportsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('content_reports', function (Blueprint $table) {
$table->increments('id');
$table->timestamps();
$table->morphs('object');
$table->unsignedInteger('author_id')->index();
$table->text('message');
$table->foreign('author_id')->references('id')->on('users')
->onDelete('cascade');
// we can't add a foreign key constraint on the morph column, need to check manually
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('content_reports');
}
}

@ -0,0 +1,41 @@
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateNotificationsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('notifications', function (Blueprint $table) {
$table->increments('id');
$table->timestamps();
$table->unsignedInteger('user_id')->index();
$table->unsignedInteger('actor_id')->index()->nullable(); // who did it
$table->string('action'); // what happened, e.g.: favourited, mentioned, forked, commented
$table->nullableMorphs('context'); // the action target or context
$table->foreign('actor_id')->references('id')->on('users')
->onDelete('cascade');
$table->foreign('user_id')->references('id')->on('users')
->onDelete('cascade');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('notifications');
}
}
Loading…
Cancel
Save