lots of improvements
This commit is contained in:
@@ -14,6 +14,7 @@ return new class extends Migration
|
||||
Schema::create('users', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('name');
|
||||
$table->string('slug')->unique();
|
||||
$table->string('email')->unique();
|
||||
$table->timestamp('email_verified_at')->nullable();
|
||||
$table->string('password');
|
||||
|
||||
+5
-4
@@ -11,8 +11,8 @@ return new class extends Migration
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('users', function (Blueprint $table) {
|
||||
$table->string('slug')->unique()->after('name');
|
||||
Schema::table('reviews', function (Blueprint $table) {
|
||||
$table->foreignId('platform_id')->nullable()->after('rating')->constrained()->onDelete('set null');
|
||||
});
|
||||
}
|
||||
|
||||
@@ -21,8 +21,9 @@ return new class extends Migration
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('users', function (Blueprint $table) {
|
||||
$table->dropColumn('slug');
|
||||
Schema::table('reviews', function (Blueprint $table) {
|
||||
$table->dropForeign(['platform_id']);
|
||||
$table->dropColumn('platform_id');
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
|
||||
class CreateAcquaintancesFriendshipTable extends Migration
|
||||
{
|
||||
|
||||
public function up()
|
||||
{
|
||||
|
||||
Schema::create(config('acquaintances.tables.friendships'), function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->morphs('sender');
|
||||
$table->morphs('recipient');
|
||||
$table->string('status')->default('pending')->comment('pending/accepted/denied/blocked/');
|
||||
$table->timestamps();
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists(config('acquaintances.tables.friendships'));
|
||||
}
|
||||
|
||||
}
|
||||
+38
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
|
||||
/**
|
||||
* Class CreateFriendshipsGroupsTable
|
||||
*/
|
||||
class CreateAcquaintancesFriendshipsGroupsTable extends Migration
|
||||
{
|
||||
|
||||
public function up()
|
||||
{
|
||||
|
||||
Schema::create(config('acquaintances.tables.friendship_groups'), function (Blueprint $table) {
|
||||
$table->id();
|
||||
|
||||
$table->unsignedBigInteger('friendship_id')->unsigned();
|
||||
$table->morphs('friend');
|
||||
$table->integer('group_id')->unsigned();
|
||||
|
||||
$table->foreign('friendship_id')
|
||||
->references('id')
|
||||
->on(config('acquaintances.tables.friendships'))
|
||||
->onDelete('cascade');
|
||||
|
||||
$table->unique(['friendship_id', 'friend_id', 'friend_type', 'group_id'], 'unique');
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists(config('acquaintances.tables.friendship_groups'));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Multicaret\Acquaintances\Interaction;
|
||||
|
||||
class CreateAcquaintancesInteractionsTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create(config('acquaintances.tables.interactions', 'interactions'), function (Blueprint $table) {
|
||||
$table->id();
|
||||
|
||||
$userModel = Interaction::getUserModelName();
|
||||
$userModel = (new $userModel);
|
||||
$userIdFkColumnName = config('acquaintances.tables.interactions_user_id_fk_column_name', 'user_id');
|
||||
|
||||
$userIdFkType = config('acquaintances.tables.interactions_user_id_fk_column_type');
|
||||
$table->{$userIdFkType}($userIdFkColumnName)->index();
|
||||
$table->morphs('subject');
|
||||
$table->string('relation')->default('follow')->comment('follow/like/subscribe/favorite/upvote/downvote');
|
||||
$table->double('relation_value')->nullable();
|
||||
$table->string('relation_type')->nullable();
|
||||
$table->timestamps();
|
||||
|
||||
|
||||
$table->foreign($userIdFkColumnName)
|
||||
->references($userModel->getKeyName())
|
||||
->on($userModel->getTable())
|
||||
->onUpdate('cascade')
|
||||
->onDelete('cascade');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::table(config('acquaintances.tables.interactions', 'interactions'), function ($table) {
|
||||
$table->dropForeign(config('acquaintances.tables.interactions', 'interactions').'_user_id_foreign');
|
||||
});
|
||||
|
||||
Schema::drop(config('acquaintances.tables.interactions', 'interactions'));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('forum_categories', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('name');
|
||||
$table->string('slug')->unique();
|
||||
$table->text('description')->nullable();
|
||||
$table->integer('order')->default(0);
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('forum_categories');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('forum_threads', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('category_id')->constrained('forum_categories')->onDelete('cascade');
|
||||
$table->foreignId('user_id')->constrained()->onDelete('cascade');
|
||||
$table->string('title');
|
||||
$table->string('slug')->unique();
|
||||
$table->boolean('is_sticky')->default(false);
|
||||
$table->boolean('is_locked')->default(false);
|
||||
$table->integer('views')->default(0);
|
||||
$table->timestamp('last_activity_at')->nullable();
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('forum_threads');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('forum_topics', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('thread_id')->constrained('forum_threads')->onDelete('cascade');
|
||||
$table->foreignId('user_id')->constrained()->onDelete('cascade');
|
||||
$table->string('title');
|
||||
$table->text('content');
|
||||
$table->boolean('is_pinned')->default(false);
|
||||
$table->timestamp('last_activity_at')->nullable();
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('forum_topics');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('forum_posts', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('topic_id')->constrained('forum_topics')->onDelete('cascade');
|
||||
$table->foreignId('user_id')->constrained()->onDelete('cascade');
|
||||
$table->text('content');
|
||||
$table->boolean('is_solution')->default(false);
|
||||
$table->timestamp('edited_at')->nullable();
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('forum_posts');
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user