more migrations
This commit is contained in:
@@ -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');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
class CreateDiscussionFollowsTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('discussion_follows', 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('discussion_follows');
|
||||
}
|
||||
}
|
||||
@@ -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');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user