Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UUID instead of id #10

Closed
ctf0 opened this issue Jun 30, 2019 · 3 comments

Comments

Projects
None yet
2 participants
@ctf0
Copy link
Contributor

commented Jun 30, 2019

is it possible to update the docs on what to change in order to use UUIDs instead if inc-id ?

@mkwsra

This comment has been minimized.

Copy link
Member

commented Jun 30, 2019

Not that I've tried it with this library but as I quick look you need to change the following places:
1- Migration files
2- Models
3- The logic of manipulating relations within Interaction.php

@ctf0

This comment has been minimized.

Copy link
Contributor Author

commented Jul 3, 2019

after testing, so far all needed was to change the migration fields types.
the friendship works correctly, but havent tested on groups or interactions yet.

@ctf0

This comment has been minimized.

Copy link
Contributor Author

commented Jul 7, 2019

here are the changes needed

  • for friends
<?php

use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateAcquaintancesFriendshipTable extends Migration
{
    public function up()
    {
        Schema::create(config('acquaintances.tables.friendships'), function (Blueprint $table) {
            $table->increments('id');
            $table->uuid('sender_id');
            $table->string('sender_type');
            $table->uuid('recipient_id');
            $table->string('recipient_type');
            $table->string('status')->default('pending')->comment('pending/accepted/denied/blocked/');
            $table->timestamps();
        });
    }

    public function down()
    {
        Schema::dropIfExists(config('acquaintances.tables.friendships'));
    }
}
  • for groups
<?php

use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

/**
 * Class CreateFriendshipsGroupsTable.
 */
class CreateAcquaintancesFriendshipsGroupsTable extends Migration
{
    public function up()
    {
        Schema::create(config('acquaintances.tables.friendship_groups'), function (Blueprint $table) {
            $table->integer('friendship_id')->unsigned();
            $table->uuid('friend_id');
            $table->string('friend_type');
            $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'));
    }
}
  • for interactions
<?php

use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateAcquaintancesInteractionsTable extends Migration
{
    /**
     * Run the migrations.
     */
    public function up()
    {
        Schema::create(config('acquaintances.tables.interactions', 'interactions'), function (Blueprint $table) {
            $table->uuid('user_id');
            $table->uuid('subject_id');
            $table->string('subject_type');
            $table->string('relation')->default('follow')->comment('follow/like/subscribe/favorite/upvote/downvote');
            $table->integer('relation_value')->nullable();
            $table->string('relation_type')->nullable();
            $table->timestamp('created_at');
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down()
    {
        Schema::drop(config('acquaintances.tables.interactions', 'interactions'));
    }
}

@ctf0 ctf0 closed this Jul 8, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.