77
88class CreateChatTables extends Migration
99{
10+ protected function schema ()
11+ {
12+ $ connection = config ('musonza_chat.database_connection ' );
13+
14+ return $ connection ? Schema::connection ($ connection ) : Schema::getFacadeRoot ();
15+ }
16+
1017 /**
1118 * Run the migrations.
1219 *
1320 * @return void
1421 */
1522 public function up ()
1623 {
17- Schema:: create (ConfigurationManager::CONVERSATIONS_TABLE , function (Blueprint $ table ) {
24+ $ this -> schema ()-> create (ConfigurationManager::CONVERSATIONS_TABLE , function (Blueprint $ table ) {
1825 $ table ->bigIncrements ('id ' );
1926 $ table ->boolean ('private ' )->default (true );
2027 $ table ->boolean ('direct_message ' )->default (false );
2128 $ table ->text ('data ' )->nullable ();
2229 $ table ->timestamps ();
2330 });
2431
25- Schema:: create (ConfigurationManager::PARTICIPATION_TABLE , function (Blueprint $ table ) {
32+ $ this -> schema ()-> create (ConfigurationManager::PARTICIPATION_TABLE , function (Blueprint $ table ) {
2633 $ table ->bigIncrements ('id ' );
2734 $ table ->bigInteger ('conversation_id ' )->unsigned ();
2835 $ table ->bigInteger ('messageable_id ' )->unsigned ();
@@ -38,7 +45,7 @@ public function up()
3845 ->onDelete ('cascade ' );
3946 });
4047
41- Schema:: create (ConfigurationManager::MESSAGES_TABLE , function (Blueprint $ table ) {
48+ $ this -> schema ()-> create (ConfigurationManager::MESSAGES_TABLE , function (Blueprint $ table ) {
4249 $ table ->bigIncrements ('id ' );
4350 $ table ->text ('body ' );
4451 $ table ->bigInteger ('conversation_id ' )->unsigned ();
@@ -58,7 +65,7 @@ public function up()
5865 ->onDelete ('cascade ' );
5966 });
6067
61- Schema:: create (ConfigurationManager::MESSAGE_NOTIFICATIONS_TABLE , function (Blueprint $ table ) {
68+ $ this -> schema ()-> create (ConfigurationManager::MESSAGE_NOTIFICATIONS_TABLE , function (Blueprint $ table ) {
6269 $ table ->bigIncrements ('id ' );
6370 $ table ->bigInteger ('message_id ' )->unsigned ();
6471 $ table ->bigInteger ('messageable_id ' )->unsigned ();
@@ -97,9 +104,9 @@ public function up()
97104 */
98105 public function down ()
99106 {
100- Schema:: dropIfExists (ConfigurationManager::MESSAGE_NOTIFICATIONS_TABLE );
101- Schema:: dropIfExists (ConfigurationManager::MESSAGES_TABLE );
102- Schema:: dropIfExists (ConfigurationManager::PARTICIPATION_TABLE );
103- Schema:: dropIfExists (ConfigurationManager::CONVERSATIONS_TABLE );
107+ $ this -> schema ()-> dropIfExists (ConfigurationManager::MESSAGE_NOTIFICATIONS_TABLE );
108+ $ this -> schema ()-> dropIfExists (ConfigurationManager::MESSAGES_TABLE );
109+ $ this -> schema ()-> dropIfExists (ConfigurationManager::PARTICIPATION_TABLE );
110+ $ this -> schema ()-> dropIfExists (ConfigurationManager::CONVERSATIONS_TABLE );
104111 }
105112}
0 commit comments