@@ -11,28 +11,30 @@ public function up()
1111 $ tableName = config ('request-analytics.database.table ' , 'request_analytics ' );
1212 $ connection = config ('request-analytics.database.connection ' );
1313
14- Schema::connection ($ connection )->create ($ tableName , function (Blueprint $ table ) {
15- $ table ->id ();
16- $ table ->string ('path ' );
17- $ table ->string ('page_title ' );
18- $ table ->string ('ip_address ' );
19- $ table ->string ('operating_system ' )->nullable ();
20- $ table ->string ('browser ' )->nullable ();
21- $ table ->string ('device ' )->nullable ();
22- $ table ->string ('screen ' )->nullable ();
23- $ table ->string ('referrer ' )->nullable ();
24- $ table ->string ('country ' )->nullable ();
25- $ table ->string ('city ' )->nullable ();
26- $ table ->string ('language ' )->nullable ();
27- $ table ->tinyText ('query_params ' )->nullable ();
28- $ table ->string ('session_id ' );
29- $ table ->string ('visitor_id ' )->nullable ()->index ();
30- $ table ->unsignedBigInteger ('user_id ' )->nullable ();
31- $ table ->string ('http_method ' );
32- $ table ->string ('request_category ' );
33- $ table ->bigInteger ('response_time ' )->nullable ()->comment ('Response time in milliseconds ' );
34- $ table ->timestamp ('visited_at ' );
35- });
14+ if (! Schema::connection ($ connection )->hasTable ($ tableName )) {
15+ Schema::connection ($ connection )->create ($ tableName , function (Blueprint $ table ) {
16+ $ table ->id ();
17+ $ table ->string ('path ' );
18+ $ table ->string ('page_title ' )->nullable ();
19+ $ table ->string ('ip_address ' );
20+ $ table ->string ('operating_system ' )->nullable ();
21+ $ table ->string ('browser ' )->nullable ();
22+ $ table ->string ('device ' )->nullable ();
23+ $ table ->string ('screen ' )->nullable ();
24+ $ table ->string ('referrer ' )->nullable ();
25+ $ table ->string ('country ' )->nullable ();
26+ $ table ->string ('city ' )->nullable ();
27+ $ table ->string ('language ' )->nullable ();
28+ $ table ->text ('query_params ' )->nullable ();
29+ $ table ->string ('session_id ' );
30+ $ table ->string ('visitor_id ' )->nullable ();
31+ $ table ->unsignedBigInteger ('user_id ' )->nullable ();
32+ $ table ->string ('http_method ' );
33+ $ table ->string ('request_category ' );
34+ $ table ->bigInteger ('response_time ' )->nullable ();
35+ $ table ->timestamp ('visited_at ' );
36+ });
37+ }
3638 }
3739
3840 public function down ()
0 commit comments