diff --git a/app/Actions/MigrateBadJsonResults.php b/app/Actions/MigrateBadJsonResults.php deleted file mode 100644 index 0e7d7a1cf..000000000 --- a/app/Actions/MigrateBadJsonResults.php +++ /dev/null @@ -1,106 +0,0 @@ -bad_json_migrated) { - Notification::make() - ->title('❌ Hmmm it seems someone has already migrated the data!') - ->body('Check your results table and make sure you\'re not triggering a duplicate data migration.') - ->danger() - ->sendToDatabase($user); - - return; - } - - if (! Schema::hasTable('results')) { - Notification::make() - ->title('❌ Could not migrate bad json results!') - ->body('The "results" table is missing.') - ->danger() - ->sendToDatabase($user); - - return; - } - - if (! Schema::hasTable($tableName)) { - Notification::make() - ->title('❌ Could not migrate bad json results!') - ->body('The "results_bad_json" table is missing.') - ->danger() - ->sendToDatabase($user); - - return; - } - - /** - * Copy backup data to the new results table and reformat it. - */ - try { - DB::table($tableName)->chunkById(100, function ($results) { - foreach ($results as $result) { - $record = [ - 'service' => 'ookla', - 'ping' => $result->ping, - 'download' => $result->download, - 'upload' => $result->upload, - 'comments' => $result->comments, - 'data' => json_decode($result->data), - 'status' => match ($result->successful) { - 1 => ResultStatus::Completed, - true => ResultStatus::Completed, - default => ResultStatus::Failed, - }, - 'scheduled' => $result->scheduled, - 'created_at' => $result->created_at, - 'updated_at' => now(), - ]; - - DB::table('results')->insert($record); - } - }); - } catch (\Throwable $e) { - Log::error($e); - - Notification::make() - ->title('There was an issue migrating the data!') - ->body('Check the logs for an output of the issue.') - ->danger() - ->sendToDatabase($user); - - return; - } - - $dataSettings->bad_json_migrated = true; - - $dataSettings->save(); - - Notification::make() - ->title('Data migration completed!') - ->body('Your history has been successfully migrated.') - ->success() - ->sendToDatabase($user); - } -} diff --git a/app/Filament/Resources/ResultResource.php b/app/Filament/Resources/ResultResource.php index 4ce9a11a9..b97148752 100644 --- a/app/Filament/Resources/ResultResource.php +++ b/app/Filament/Resources/ResultResource.php @@ -2,19 +2,16 @@ namespace App\Filament\Resources; -use App\Actions\MigrateBadJsonResults; use App\Enums\ResultStatus; use App\Filament\Exports\ResultExporter; use App\Filament\Resources\ResultResource\Pages; use App\Helpers\Number; use App\Jobs\TruncateResults; use App\Models\Result; -use App\Settings\DataMigrationSettings; use Carbon\Carbon; use Filament\Forms; use Filament\Forms\Components\TextInput; use Filament\Forms\Form; -use Filament\Notifications\Notification; use Filament\Resources\Resource; use Filament\Support\Enums\Alignment; use Filament\Tables; @@ -156,8 +153,6 @@ public static function form(Form $form): Form public static function table(Table $table): Table { - $dataSettings = new DataMigrationSettings; - return $table ->columns([ Tables\Columns\TextColumn::make('id') @@ -407,21 +402,6 @@ public static function table(Table $table): Table Tables\Actions\ExportAction::make() ->exporter(ResultExporter::class) ->fileName(fn (): string => 'results-'.now()->timestamp), - Tables\Actions\Action::make('migrate') - ->action(function (): void { - Notification::make() - ->title('Starting data migration...') - ->body('This can take a little bit depending how much data you have.') - ->warning() - ->sendToDatabase(Auth::user()); - - MigrateBadJsonResults::dispatch(Auth::user()); - }) - ->hidden($dataSettings->bad_json_migrated) - ->requiresConfirmation() - ->modalHeading('Migrate History') - ->modalDescription(new HtmlString('
v0.16.0 archived the old "results" table, to migrate your history click the button below.
For more information read the docs.
')) - ->modalSubmitActionLabel('Yes, migrate it'), Tables\Actions\ActionGroup::make([ Tables\Actions\Action::make('truncate') ->action(fn () => TruncateResults::dispatch(Auth::user())) diff --git a/app/Settings/DataMigrationSettings.php b/app/Settings/DataMigrationSettings.php deleted file mode 100644 index 8823f7cbd..000000000 --- a/app/Settings/DataMigrationSettings.php +++ /dev/null @@ -1,15 +0,0 @@ -timestamp('email_verified_at')->nullable(); $table->string('password'); $table->rememberToken(); + $table->string('role')->default('user'); $table->timestamps(); }); + + User::create([ + 'name' => 'Admin', + 'email' => 'admin@example.com', + 'email_verified_at' => now(), + 'password' => Hash::make('password'), + 'role' => UserRole::Admin, + ]); } /** diff --git a/database/migrations/2022_08_31_202106_create_results_table.php b/database/migrations/2022_08_31_202106_create_results_table.php index 4b8429117..6614b8239 100644 --- a/database/migrations/2022_08_31_202106_create_results_table.php +++ b/database/migrations/2022_08_31_202106_create_results_table.php @@ -13,17 +13,15 @@ public function up(): void { Schema::create('results', function (Blueprint $table) { $table->id(); - $table->float('ping', 8, 3); - $table->unsignedBigInteger('download'); // will be stored in bytes - $table->unsignedBigInteger('upload'); // will be stored in bytes - $table->integer('server_id')->nullable(); - $table->string('server_host')->nullable(); - $table->string('server_name')->nullable(); - $table->string('url')->nullable(); + $table->string('service')->default('ookla'); + $table->float('ping', 8, 3)->nullable(); + $table->unsignedBigInteger('download')->nullable(); + $table->unsignedBigInteger('upload')->nullable(); + $table->text('comments')->nullable(); + $table->json('data')->nullable(); + $table->string('status'); $table->boolean('scheduled')->default(false); - $table->json('data'); // is a dump of the cli output in case we want more fields later - $table->timestamp('created_at') - ->useCurrent(); + $table->timestamps(); }); } diff --git a/database/migrations/2022_09_27_212959_create_admin_user.php b/database/migrations/2022_09_27_212959_create_admin_user.php deleted file mode 100644 index 8b8907026..000000000 --- a/database/migrations/2022_09_27_212959_create_admin_user.php +++ /dev/null @@ -1,29 +0,0 @@ - 'Admin', - 'email' => 'admin@example.com', - 'email_verified_at' => now(), - 'password' => Hash::make('password'), - ]); - } - - /** - * Reverse the migrations. - */ - public function down(): void - { - // - } -}; diff --git a/database/migrations/2023_01_12_135235_update_results_table.php b/database/migrations/2023_01_12_135235_update_results_table.php deleted file mode 100644 index e7081fb47..000000000 --- a/database/migrations/2023_01_12_135235_update_results_table.php +++ /dev/null @@ -1,31 +0,0 @@ -float('ping', 8, 3)->nullable()->change(); - $table->unsignedBigInteger('download')->nullable()->change(); - $table->unsignedBigInteger('upload')->nullable()->change(); - $table->json('data')->nullable()->change(); - - $table->boolean('successful')->default(true)->after('scheduled'); - }); - } - - /** - * Reverse the migrations. - */ - public function down(): void - { - // - } -}; diff --git a/database/migrations/2023_02_12_131620_add_comments_to_results_table.php b/database/migrations/2023_02_12_131620_add_comments_to_results_table.php deleted file mode 100644 index 7d566a946..000000000 --- a/database/migrations/2023_02_12_131620_add_comments_to_results_table.php +++ /dev/null @@ -1,26 +0,0 @@ -text('comments')->nullable()->after('url'); - }); - } - - /** - * Reverse the migrations. - */ - public function down(): void - { - // - } -}; diff --git a/database/migrations/2023_09_11_225054_add_role_to_users_table.php b/database/migrations/2023_09_11_225054_add_role_to_users_table.php deleted file mode 100644 index cf23b8020..000000000 --- a/database/migrations/2023_09_11_225054_add_role_to_users_table.php +++ /dev/null @@ -1,39 +0,0 @@ -string('role') - ->nullable() - ->after('remember_token'); - }); - - $user = User::first(); - - if ($user) { - $user->role = 'admin'; - - $user->save(); - } - } - - /** - * Reverse the migrations. - */ - public function down(): void - { - Schema::table('users', function (Blueprint $table) { - $table->dropColumn('role'); - }); - } -}; diff --git a/database/migrations/2024_02_18_100000_results_bad_json_table.php b/database/migrations/2024_02_18_100000_results_bad_json_table.php deleted file mode 100644 index c3f93a73e..000000000 --- a/database/migrations/2024_02_18_100000_results_bad_json_table.php +++ /dev/null @@ -1,88 +0,0 @@ -id(); - $table->string('service')->default('ookla'); - $table->float('ping', 8, 3)->nullable(); - $table->unsignedBigInteger('download')->nullable(); - $table->unsignedBigInteger('upload')->nullable(); - $table->text('comments')->nullable(); - $table->json('data')->nullable(); - $table->string('status'); - $table->boolean('scheduled')->default(false); - $table->timestamps(); - }); - } - } - - /** - * Don't disable the schedule or send a notification if there are no records. - */ - if (! DB::table('results_bad_json')->count()) { - $dataSettings = new DataMigrationSettings; - - $dataSettings->bad_json_migrated = true; - - $dataSettings->save(); - - return; - } - - $admins = User::where('role', '=', UserRole::Admin)->get(); - - foreach ($admins as $user) { - Notification::make() - ->title('Breaking change, user action required!') - ->body('v0.16.0 includes a breaking change to resolve a data quality issue. Read the release notes regarding the data migration.') - ->danger() - ->actions([ - Action::make('Release notes') - ->button() - ->url('https://github.com/alexjustesen/speedtest-tracker/releases/tag/v0.16.0') - ->openUrlInNewTab(), - ]) - ->sendToDatabase($user); - } - } - - /** - * Reverse the migrations. - */ - public function down(): void - { - Schema::drop('results'); - - if (! Schema::hasTable('results')) { - Schema::rename('results_bad_json', 'results'); - } - } -}; diff --git a/database/settings/2024_02_18_000000_create_data_migration_settings.php b/database/settings/2024_02_18_000000_create_data_migration_settings.php deleted file mode 100644 index 0b0b06e1c..000000000 --- a/database/settings/2024_02_18_000000_create_data_migration_settings.php +++ /dev/null @@ -1,11 +0,0 @@ -migrator->add('data_migration.bad_json_migrated', false); - } -};