From 98a80fc8f3ea25bc34b0f5fb48cc454b4a381dbd Mon Sep 17 00:00:00 2001 From: Philipp
Date: Mon, 16 Nov 2020 12:23:28 +0100 Subject: [PATCH] Updated Migration table --- .phpunit.result.cache | 2 +- database/migrations/create_chat_tables.php | 60 ++++++++++++---------- 2 files changed, 33 insertions(+), 29 deletions(-) diff --git a/.phpunit.result.cache b/.phpunit.result.cache index 0752ca0..c1437f3 100644 --- a/.phpunit.result.cache +++ b/.phpunit.result.cache @@ -1 +1 @@ -C:37:"PHPUnit\Runner\DefaultTestResultCache":6578:{a:2:{s:7:"defects";a:37:{s:62:"Musonza\Chat\Tests\ConversationTest::it_creates_a_conversation";i:4;s:75:"Musonza\Chat\Tests\ConversationTest::it_returns_a_conversation_given_the_id";i:4;s:71:"Musonza\Chat\Tests\ConversationTest::it_can_mark_a_conversation_as_read";i:4;s:71:"Musonza\Chat\Tests\ConversationTest::it_can_update_conversation_details";i:4;s:64:"Musonza\Chat\Tests\ConversationTest::it_can_clear_a_conversation";i:4;s:83:"Musonza\Chat\Tests\ConversationTest::it_can_create_a_conversation_between_two_users";i:4;s:79:"Musonza\Chat\Tests\ConversationTest::it_can_return_a_conversation_between_users";i:4;s:82:"Musonza\Chat\Tests\ConversationTest::it_can_remove_a_single_user_from_conversation";i:4;s:83:"Musonza\Chat\Tests\ConversationTest::it_can_remove_multiple_users_from_conversation";i:4;s:77:"Musonza\Chat\Tests\ConversationTest::it_can_add_a_single_user_to_conversation";i:4;s:78:"Musonza\Chat\Tests\ConversationTest::it_can_add_multiple_users_to_conversation";i:3;s:84:"Musonza\Chat\Tests\ConversationTest::it_can_return_a_common_conversation_among_users";i:4;s:79:"Musonza\Chat\Tests\ConversationTest::it_can_return_conversation_recent_messsage";i:4;s:107:"Musonza\Chat\Tests\ConversationTest::it_returns_last_message_as_null_when_the_very_last_message_was_deleted";i:4;s:82:"Musonza\Chat\Tests\ConversationTest::it_returns_correct_attributes_in_last_message";i:4;s:112:"Musonza\Chat\Tests\ConversationTest::it_returns_the_correct_order_of_conversations_when_updated_at_is_duplicated";i:4;s:85:"Musonza\Chat\Tests\ConversationTest::it_allows_setting_private_or_public_conversation";i:4;s:93:"Musonza\Chat\Tests\ConversationTest::it_converts_at_least_3_participants_to_public_by_default";i:4;s:101:"Musonza\Chat\Tests\ConversationTest::converting_at_least_three_participants_to_public_is_configurable";i:4;s:69:"Musonza\Chat\Tests\ConversationTest::it_filters_conversations_by_type";i:4;s:77:"Musonza\Chat\Tests\ConversationTest::it_specifies_fields_to_return_for_sender";i:4;s:53:"Musonza\Chat\Tests\MessageTest::it_can_send_a_message";i:4;s:65:"Musonza\Chat\Tests\MessageTest::it_returns_a_message_given_the_id";i:4;s:72:"Musonza\Chat\Tests\MessageTest::it_can_send_a_message_and_specificy_type";i:4;s:61:"Musonza\Chat\Tests\MessageTest::it_can_mark_a_message_as_read";i:4;s:55:"Musonza\Chat\Tests\MessageTest::it_can_delete_a_message";i:4;s:60:"Musonza\Chat\Tests\MessageTest::it_can_list_deleted_messages";i:4;s:58:"Musonza\Chat\Tests\MessageTest::it_can_tell_message_sender";i:4;s:82:"Musonza\Chat\Tests\MessageTest::it_can_return_paginated_messages_in_a_conversation";i:4;s:67:"Musonza\Chat\Tests\MessageTest::it_can_return_recent_user_messsages";i:4;s:72:"Musonza\Chat\Tests\MessageTest::it_return_unread_messages_count_for_user";i:4;s:55:"Musonza\Chat\Tests\MessageTest::it_gets_a_message_by_id";i:4;s:50:"Musonza\Chat\Tests\MessageTest::it_flags_a_message";i:4;s:69:"Musonza\Chat\Tests\NotificationsTest::it_creates_message_notification";i:4;s:70:"Musonza\Chat\Tests\NotificationsTest::it_gets_all_unread_notifications";i:4;s:83:"Musonza\Chat\Tests\NotificationsTest::it_gets_unread_notifications_per_conversation";i:4;s:63:"Musonza\Chat\Tests\PaginationTest::it_can_set_pagination_params";i:4;}s:5:"times";a:37:{s:62:"Musonza\Chat\Tests\ConversationTest::it_creates_a_conversation";d:0.615;s:75:"Musonza\Chat\Tests\ConversationTest::it_returns_a_conversation_given_the_id";d:0.513;s:71:"Musonza\Chat\Tests\ConversationTest::it_can_mark_a_conversation_as_read";d:0.484;s:71:"Musonza\Chat\Tests\ConversationTest::it_can_update_conversation_details";d:0.512;s:64:"Musonza\Chat\Tests\ConversationTest::it_can_clear_a_conversation";d:0.482;s:83:"Musonza\Chat\Tests\ConversationTest::it_can_create_a_conversation_between_two_users";d:0.46;s:79:"Musonza\Chat\Tests\ConversationTest::it_can_return_a_conversation_between_users";d:0.505;s:82:"Musonza\Chat\Tests\ConversationTest::it_can_remove_a_single_user_from_conversation";d:0.483;s:83:"Musonza\Chat\Tests\ConversationTest::it_can_remove_multiple_users_from_conversation";d:0.47;s:77:"Musonza\Chat\Tests\ConversationTest::it_can_add_a_single_user_to_conversation";d:0.551;s:78:"Musonza\Chat\Tests\ConversationTest::it_can_add_multiple_users_to_conversation";d:0.873;s:84:"Musonza\Chat\Tests\ConversationTest::it_can_return_a_common_conversation_among_users";d:0.528;s:79:"Musonza\Chat\Tests\ConversationTest::it_can_return_conversation_recent_messsage";d:0.477;s:107:"Musonza\Chat\Tests\ConversationTest::it_returns_last_message_as_null_when_the_very_last_message_was_deleted";d:0.47;s:82:"Musonza\Chat\Tests\ConversationTest::it_returns_correct_attributes_in_last_message";d:0.484;s:112:"Musonza\Chat\Tests\ConversationTest::it_returns_the_correct_order_of_conversations_when_updated_at_is_duplicated";d:0.498;s:85:"Musonza\Chat\Tests\ConversationTest::it_allows_setting_private_or_public_conversation";d:0.484;s:93:"Musonza\Chat\Tests\ConversationTest::it_converts_at_least_3_participants_to_public_by_default";d:0.637;s:101:"Musonza\Chat\Tests\ConversationTest::converting_at_least_three_participants_to_public_is_configurable";d:0.646;s:69:"Musonza\Chat\Tests\ConversationTest::it_filters_conversations_by_type";d:0.603;s:77:"Musonza\Chat\Tests\ConversationTest::it_specifies_fields_to_return_for_sender";d:0.704;s:53:"Musonza\Chat\Tests\MessageTest::it_can_send_a_message";d:0.532;s:65:"Musonza\Chat\Tests\MessageTest::it_returns_a_message_given_the_id";d:0.544;s:72:"Musonza\Chat\Tests\MessageTest::it_can_send_a_message_and_specificy_type";d:0.543;s:61:"Musonza\Chat\Tests\MessageTest::it_can_mark_a_message_as_read";d:1.043;s:55:"Musonza\Chat\Tests\MessageTest::it_can_delete_a_message";d:0.515;s:60:"Musonza\Chat\Tests\MessageTest::it_can_list_deleted_messages";d:0.613;s:58:"Musonza\Chat\Tests\MessageTest::it_can_tell_message_sender";d:0.507;s:82:"Musonza\Chat\Tests\MessageTest::it_can_return_paginated_messages_in_a_conversation";d:0.501;s:67:"Musonza\Chat\Tests\MessageTest::it_can_return_recent_user_messsages";d:0.53;s:72:"Musonza\Chat\Tests\MessageTest::it_return_unread_messages_count_for_user";d:0.581;s:55:"Musonza\Chat\Tests\MessageTest::it_gets_a_message_by_id";d:0.558;s:50:"Musonza\Chat\Tests\MessageTest::it_flags_a_message";d:0.534;s:69:"Musonza\Chat\Tests\NotificationsTest::it_creates_message_notification";d:0.539;s:70:"Musonza\Chat\Tests\NotificationsTest::it_gets_all_unread_notifications";d:0.5;s:83:"Musonza\Chat\Tests\NotificationsTest::it_gets_unread_notifications_per_conversation";d:0.47;s:63:"Musonza\Chat\Tests\PaginationTest::it_can_set_pagination_params";d:0.51;}}} \ No newline at end of file +C:37:"PHPUnit\Runner\DefaultTestResultCache":6582:{a:2:{s:7:"defects";a:37:{s:62:"Musonza\Chat\Tests\ConversationTest::it_creates_a_conversation";i:4;s:75:"Musonza\Chat\Tests\ConversationTest::it_returns_a_conversation_given_the_id";i:4;s:71:"Musonza\Chat\Tests\ConversationTest::it_can_mark_a_conversation_as_read";i:4;s:71:"Musonza\Chat\Tests\ConversationTest::it_can_update_conversation_details";i:4;s:64:"Musonza\Chat\Tests\ConversationTest::it_can_clear_a_conversation";i:4;s:83:"Musonza\Chat\Tests\ConversationTest::it_can_create_a_conversation_between_two_users";i:4;s:79:"Musonza\Chat\Tests\ConversationTest::it_can_return_a_conversation_between_users";i:4;s:82:"Musonza\Chat\Tests\ConversationTest::it_can_remove_a_single_user_from_conversation";i:4;s:83:"Musonza\Chat\Tests\ConversationTest::it_can_remove_multiple_users_from_conversation";i:4;s:77:"Musonza\Chat\Tests\ConversationTest::it_can_add_a_single_user_to_conversation";i:4;s:78:"Musonza\Chat\Tests\ConversationTest::it_can_add_multiple_users_to_conversation";i:3;s:84:"Musonza\Chat\Tests\ConversationTest::it_can_return_a_common_conversation_among_users";i:4;s:79:"Musonza\Chat\Tests\ConversationTest::it_can_return_conversation_recent_messsage";i:4;s:107:"Musonza\Chat\Tests\ConversationTest::it_returns_last_message_as_null_when_the_very_last_message_was_deleted";i:4;s:82:"Musonza\Chat\Tests\ConversationTest::it_returns_correct_attributes_in_last_message";i:4;s:112:"Musonza\Chat\Tests\ConversationTest::it_returns_the_correct_order_of_conversations_when_updated_at_is_duplicated";i:4;s:85:"Musonza\Chat\Tests\ConversationTest::it_allows_setting_private_or_public_conversation";i:4;s:93:"Musonza\Chat\Tests\ConversationTest::it_converts_at_least_3_participants_to_public_by_default";i:4;s:101:"Musonza\Chat\Tests\ConversationTest::converting_at_least_three_participants_to_public_is_configurable";i:4;s:69:"Musonza\Chat\Tests\ConversationTest::it_filters_conversations_by_type";i:4;s:77:"Musonza\Chat\Tests\ConversationTest::it_specifies_fields_to_return_for_sender";i:4;s:53:"Musonza\Chat\Tests\MessageTest::it_can_send_a_message";i:4;s:65:"Musonza\Chat\Tests\MessageTest::it_returns_a_message_given_the_id";i:4;s:72:"Musonza\Chat\Tests\MessageTest::it_can_send_a_message_and_specificy_type";i:4;s:61:"Musonza\Chat\Tests\MessageTest::it_can_mark_a_message_as_read";i:4;s:55:"Musonza\Chat\Tests\MessageTest::it_can_delete_a_message";i:4;s:60:"Musonza\Chat\Tests\MessageTest::it_can_list_deleted_messages";i:4;s:58:"Musonza\Chat\Tests\MessageTest::it_can_tell_message_sender";i:4;s:82:"Musonza\Chat\Tests\MessageTest::it_can_return_paginated_messages_in_a_conversation";i:4;s:67:"Musonza\Chat\Tests\MessageTest::it_can_return_recent_user_messsages";i:4;s:72:"Musonza\Chat\Tests\MessageTest::it_return_unread_messages_count_for_user";i:4;s:55:"Musonza\Chat\Tests\MessageTest::it_gets_a_message_by_id";i:4;s:50:"Musonza\Chat\Tests\MessageTest::it_flags_a_message";i:4;s:69:"Musonza\Chat\Tests\NotificationsTest::it_creates_message_notification";i:4;s:70:"Musonza\Chat\Tests\NotificationsTest::it_gets_all_unread_notifications";i:4;s:83:"Musonza\Chat\Tests\NotificationsTest::it_gets_unread_notifications_per_conversation";i:4;s:63:"Musonza\Chat\Tests\PaginationTest::it_can_set_pagination_params";i:4;}s:5:"times";a:37:{s:62:"Musonza\Chat\Tests\ConversationTest::it_creates_a_conversation";d:0.686;s:75:"Musonza\Chat\Tests\ConversationTest::it_returns_a_conversation_given_the_id";d:0.468;s:71:"Musonza\Chat\Tests\ConversationTest::it_can_mark_a_conversation_as_read";d:0.522;s:71:"Musonza\Chat\Tests\ConversationTest::it_can_update_conversation_details";d:0.494;s:64:"Musonza\Chat\Tests\ConversationTest::it_can_clear_a_conversation";d:0.523;s:83:"Musonza\Chat\Tests\ConversationTest::it_can_create_a_conversation_between_two_users";d:0.551;s:79:"Musonza\Chat\Tests\ConversationTest::it_can_return_a_conversation_between_users";d:0.449;s:82:"Musonza\Chat\Tests\ConversationTest::it_can_remove_a_single_user_from_conversation";d:0.44;s:83:"Musonza\Chat\Tests\ConversationTest::it_can_remove_multiple_users_from_conversation";d:0.439;s:77:"Musonza\Chat\Tests\ConversationTest::it_can_add_a_single_user_to_conversation";d:0.512;s:78:"Musonza\Chat\Tests\ConversationTest::it_can_add_multiple_users_to_conversation";d:0.857;s:84:"Musonza\Chat\Tests\ConversationTest::it_can_return_a_common_conversation_among_users";d:0.463;s:79:"Musonza\Chat\Tests\ConversationTest::it_can_return_conversation_recent_messsage";d:0.454;s:107:"Musonza\Chat\Tests\ConversationTest::it_returns_last_message_as_null_when_the_very_last_message_was_deleted";d:0.453;s:82:"Musonza\Chat\Tests\ConversationTest::it_returns_correct_attributes_in_last_message";d:0.549;s:112:"Musonza\Chat\Tests\ConversationTest::it_returns_the_correct_order_of_conversations_when_updated_at_is_duplicated";d:0.79;s:85:"Musonza\Chat\Tests\ConversationTest::it_allows_setting_private_or_public_conversation";d:0.471;s:93:"Musonza\Chat\Tests\ConversationTest::it_converts_at_least_3_participants_to_public_by_default";d:0.545;s:101:"Musonza\Chat\Tests\ConversationTest::converting_at_least_three_participants_to_public_is_configurable";d:0.6;s:69:"Musonza\Chat\Tests\ConversationTest::it_filters_conversations_by_type";d:0.454;s:77:"Musonza\Chat\Tests\ConversationTest::it_specifies_fields_to_return_for_sender";d:0.517;s:53:"Musonza\Chat\Tests\MessageTest::it_can_send_a_message";d:0.581;s:65:"Musonza\Chat\Tests\MessageTest::it_returns_a_message_given_the_id";d:0.449;s:72:"Musonza\Chat\Tests\MessageTest::it_can_send_a_message_and_specificy_type";d:0.438;s:61:"Musonza\Chat\Tests\MessageTest::it_can_mark_a_message_as_read";d:0.478;s:55:"Musonza\Chat\Tests\MessageTest::it_can_delete_a_message";d:0.442;s:60:"Musonza\Chat\Tests\MessageTest::it_can_list_deleted_messages";d:0.447;s:58:"Musonza\Chat\Tests\MessageTest::it_can_tell_message_sender";d:0.451;s:82:"Musonza\Chat\Tests\MessageTest::it_can_return_paginated_messages_in_a_conversation";d:0.461;s:67:"Musonza\Chat\Tests\MessageTest::it_can_return_recent_user_messsages";d:0.465;s:72:"Musonza\Chat\Tests\MessageTest::it_return_unread_messages_count_for_user";d:0.465;s:55:"Musonza\Chat\Tests\MessageTest::it_gets_a_message_by_id";d:0.464;s:50:"Musonza\Chat\Tests\MessageTest::it_flags_a_message";d:0.464;s:69:"Musonza\Chat\Tests\NotificationsTest::it_creates_message_notification";d:0.455;s:70:"Musonza\Chat\Tests\NotificationsTest::it_gets_all_unread_notifications";d:0.453;s:83:"Musonza\Chat\Tests\NotificationsTest::it_gets_unread_notifications_per_conversation";d:0.451;s:63:"Musonza\Chat\Tests\PaginationTest::it_can_set_pagination_params";d:0.442;}}} \ No newline at end of file diff --git a/database/migrations/create_chat_tables.php b/database/migrations/create_chat_tables.php index d3ce6de..a39f0ab 100644 --- a/database/migrations/create_chat_tables.php +++ b/database/migrations/create_chat_tables.php @@ -28,52 +28,54 @@ public function __construct() public function up() { Schema::create('mc_conversations', function (Blueprint $table) { - $table->bigIncrements('id'); + $table->id(); $table->boolean('private')->default(true); $table->text('data')->nullable(); $table->timestamps(); }); Schema::create('mc_messages', function (Blueprint $table) { - $table->bigIncrements('id'); + $table->id(); $table->text('body'); - $table->bigInteger('conversation_id')->unsigned(); - $table->bigInteger('user_id')->unsigned(); + + $table->unsignedBigInteger('conversation_id'); + $table->unsignedBigInteger('user_id'); $table->string('type')->default('text'); $table->timestamps(); $table->foreign('user_id') - ->references($this->userModelPrimaryKey) - ->on($this->userModelTable) - ->onDelete('cascade'); + ->references($this->userModelPrimaryKey) + ->on($this->userModelTable) + ->onDelete('cascade'); $table->foreign('conversation_id') - ->references('id') - ->on('mc_conversations') - ->onDelete('cascade'); + ->references('id') + ->on('mc_conversations') + ->onDelete('cascade'); }); Schema::create('mc_conversation_user', function (Blueprint $table) { - $table->bigInteger('user_id')->unsigned(); - $table->bigInteger('conversation_id')->unsigned(); + $table->unsignedBigInteger('user_id'); + $table->unsignedBigInteger('conversation_id'); $table->primary(['user_id', 'conversation_id']); $table->timestamps(); $table->foreign('conversation_id') - ->references('id')->on('mc_conversations') - ->onDelete('cascade'); + ->references('id') + ->on('mc_conversations') + ->onDelete('cascade'); $table->foreign('user_id') - ->references($this->userModelPrimaryKey) - ->on($this->userModelTable) - ->onDelete('cascade'); + ->references($this->userModelPrimaryKey) + ->on($this->userModelTable) + ->onDelete('cascade'); }); Schema::create('mc_message_notification', function (Blueprint $table) { - $table->bigIncrements('id'); - $table->bigInteger('message_id')->unsigned(); - $table->bigInteger('conversation_id')->unsigned(); - $table->bigInteger('user_id')->unsigned(); + $table->id(); + $table->unsignedBigInteger('message_id'); + $table->unsignedBigInteger('conversation_id'); + $table->unsignedBigInteger('user_id'); $table->boolean('is_seen')->default(false); $table->boolean('is_sender')->default(false); $table->boolean('flagged')->default(false); @@ -83,17 +85,19 @@ public function up() $table->index(['user_id', 'message_id']); $table->foreign('message_id') - ->references('id')->on('mc_messages') - ->onDelete('cascade'); + ->references('id') + ->on('mc_messages') + ->onDelete('cascade'); $table->foreign('conversation_id') - ->references('id')->on('mc_conversations') - ->onDelete('cascade'); + ->references('id') + ->on('mc_conversations') + ->onDelete('cascade'); $table->foreign('user_id') - ->references($this->userModelPrimaryKey) - ->on($this->userModelTable) - ->onDelete('cascade'); + ->references($this->userModelPrimaryKey) + ->on($this->userModelTable) + ->onDelete('cascade'); }); }