diff --git a/app/Http/Middleware/SetUserTimezone.php b/app/Http/Middleware/SetUserTimezone.php new file mode 100644 index 000000000..d073a0ed2 --- /dev/null +++ b/app/Http/Middleware/SetUserTimezone.php @@ -0,0 +1,26 @@ +id(); + $table->string('metric_type', 50)->index(); // 'cpu' or 'ram' + $table->decimal('value', 8, 2); // The metric value (percentage or GB) + $table->timestamp('recorded_at')->index(); // When the metric was recorded + $table->timestamps(); + + // Composite index for efficient querying + $table->index(['metric_type', 'recorded_at']); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('system_metrics'); + } +}; diff --git a/database/migrations/2025_10_22_204937_add_sort_date_to_signup_stats_table.php b/database/migrations/2025_10_22_204937_add_sort_date_to_signup_stats_table.php new file mode 100644 index 000000000..87362a67e --- /dev/null +++ b/database/migrations/2025_10_22_204937_add_sort_date_to_signup_stats_table.php @@ -0,0 +1,39 @@ +date('sort_date')->nullable()->after('month'); + $table->index('sort_date'); + }); + + // Populate sort_date for existing records + // Parse month strings like "October 2025" to create sortable dates + DB::statement(" + UPDATE signup_stats + SET sort_date = STR_TO_DATE(CONCAT('01 ', month), '%d %M %Y') + WHERE sort_date IS NULL AND month IS NOT NULL + "); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::table('signup_stats', function (Blueprint $table) { + $table->dropIndex(['sort_date']); + $table->dropColumn('sort_date'); + }); + } +}; diff --git a/database/migrations/2025_10_23_094253_add_timezone_to_users_table.php b/database/migrations/2025_10_23_094253_add_timezone_to_users_table.php new file mode 100644 index 000000000..aeb3a20d1 --- /dev/null +++ b/database/migrations/2025_10_23_094253_add_timezone_to_users_table.php @@ -0,0 +1,30 @@ +string('timezone', 50)->default('UTC')->after('style'); + }); + } + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::table('users', function (Blueprint $table) { + $table->dropColumn('timezone'); + }); + } +}; diff --git a/database/migrations/2025_10_23_100000_add_movie_layout_to_users_table.php b/database/migrations/2025_10_23_100000_add_movie_layout_to_users_table.php new file mode 100644 index 000000000..5a8b6049e --- /dev/null +++ b/database/migrations/2025_10_23_100000_add_movie_layout_to_users_table.php @@ -0,0 +1,30 @@ +tinyInteger('movie_layout')->default(2)->comment('1=1-column, 2=2-columns')->after('timezone'); + }); + } + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::table('users', function (Blueprint $table) { + $table->dropColumn('movie_layout'); + }); + } +}; diff --git a/database/migrations/2025_10_24_000000_create_user_activity_stats_table.php b/database/migrations/2025_10_24_000000_create_user_activity_stats_table.php new file mode 100644 index 000000000..07007aefe --- /dev/null +++ b/database/migrations/2025_10_24_000000_create_user_activity_stats_table.php @@ -0,0 +1,33 @@ +id(); + $table->date('stat_date')->index(); + $table->integer('downloads_count')->default(0); + $table->integer('api_hits_count')->default(0); + $table->timestamps(); + + // Ensure one record per date + $table->unique('stat_date'); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('user_activity_stats'); + } +};