parent
8fb5d30513
commit
ce88fd3978
@ -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'); |
||||
} |
||||
} |
@ -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 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…
Reference in new issue