Skip to content

Commit 98a80fc

Browse files
author
Philipp
committed
Updated Migration table
1 parent bba7215 commit 98a80fc

File tree

2 files changed

+33
-29
lines changed

2 files changed

+33
-29
lines changed

.phpunit.result.cache

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +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;}}}
1+
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;}}}

database/migrations/create_chat_tables.php

Lines changed: 32 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -28,52 +28,54 @@ public function __construct()
2828
public function up()
2929
{
3030
Schema::create('mc_conversations', function (Blueprint $table) {
31-
$table->bigIncrements('id');
31+
$table->id();
3232
$table->boolean('private')->default(true);
3333
$table->text('data')->nullable();
3434
$table->timestamps();
3535
});
3636

3737
Schema::create('mc_messages', function (Blueprint $table) {
38-
$table->bigIncrements('id');
38+
$table->id();
3939
$table->text('body');
40-
$table->bigInteger('conversation_id')->unsigned();
41-
$table->bigInteger('user_id')->unsigned();
40+
41+
$table->unsignedBigInteger('conversation_id');
42+
$table->unsignedBigInteger('user_id');
4243
$table->string('type')->default('text');
4344
$table->timestamps();
4445

4546
$table->foreign('user_id')
46-
->references($this->userModelPrimaryKey)
47-
->on($this->userModelTable)
48-
->onDelete('cascade');
47+
->references($this->userModelPrimaryKey)
48+
->on($this->userModelTable)
49+
->onDelete('cascade');
4950

5051
$table->foreign('conversation_id')
51-
->references('id')
52-
->on('mc_conversations')
53-
->onDelete('cascade');
52+
->references('id')
53+
->on('mc_conversations')
54+
->onDelete('cascade');
5455
});
5556

5657
Schema::create('mc_conversation_user', function (Blueprint $table) {
57-
$table->bigInteger('user_id')->unsigned();
58-
$table->bigInteger('conversation_id')->unsigned();
58+
$table->unsignedBigInteger('user_id');
59+
$table->unsignedBigInteger('conversation_id');
5960
$table->primary(['user_id', 'conversation_id']);
6061
$table->timestamps();
6162

6263
$table->foreign('conversation_id')
63-
->references('id')->on('mc_conversations')
64-
->onDelete('cascade');
64+
->references('id')
65+
->on('mc_conversations')
66+
->onDelete('cascade');
6567

6668
$table->foreign('user_id')
67-
->references($this->userModelPrimaryKey)
68-
->on($this->userModelTable)
69-
->onDelete('cascade');
69+
->references($this->userModelPrimaryKey)
70+
->on($this->userModelTable)
71+
->onDelete('cascade');
7072
});
7173

7274
Schema::create('mc_message_notification', function (Blueprint $table) {
73-
$table->bigIncrements('id');
74-
$table->bigInteger('message_id')->unsigned();
75-
$table->bigInteger('conversation_id')->unsigned();
76-
$table->bigInteger('user_id')->unsigned();
75+
$table->id();
76+
$table->unsignedBigInteger('message_id');
77+
$table->unsignedBigInteger('conversation_id');
78+
$table->unsignedBigInteger('user_id');
7779
$table->boolean('is_seen')->default(false);
7880
$table->boolean('is_sender')->default(false);
7981
$table->boolean('flagged')->default(false);
@@ -83,17 +85,19 @@ public function up()
8385
$table->index(['user_id', 'message_id']);
8486

8587
$table->foreign('message_id')
86-
->references('id')->on('mc_messages')
87-
->onDelete('cascade');
88+
->references('id')
89+
->on('mc_messages')
90+
->onDelete('cascade');
8891

8992
$table->foreign('conversation_id')
90-
->references('id')->on('mc_conversations')
91-
->onDelete('cascade');
93+
->references('id')
94+
->on('mc_conversations')
95+
->onDelete('cascade');
9296

9397
$table->foreign('user_id')
94-
->references($this->userModelPrimaryKey)
95-
->on($this->userModelTable)
96-
->onDelete('cascade');
98+
->references($this->userModelPrimaryKey)
99+
->on($this->userModelTable)
100+
->onDelete('cascade');
97101
});
98102
}
99103

0 commit comments

Comments
 (0)