Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add migration to convert false tracking fields to null #272

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Support\Facades\DB;

class UpdateShortUrlVisitsTableConvertFalseValuesToNull extends Migration
{
public function up(): void
{
DB::transaction(static function (): void {
DB::connection(config('short-url.connection'))
->table('short_url_visits')
->update([
'ip_address' => DB::raw("CASE WHEN ip_address = '0' THEN NULL ELSE ip_address END"),
'operating_system' => DB::raw("CASE WHEN operating_system = '0' THEN NULL ELSE operating_system END"),
'operating_system_version' => DB::raw("CASE WHEN operating_system_version = '0' THEN NULL ELSE operating_system_version END"),
'browser' => DB::raw("CASE WHEN browser = '0' THEN NULL ELSE browser END"),
'browser_version' => DB::raw("CASE WHEN browser_version = '0' THEN NULL ELSE browser_version END"),
'referer_url' => DB::raw("CASE WHEN referer_url = '0' THEN NULL ELSE referer_url END"),
'device_type' => DB::raw("CASE WHEN device_type = '0' THEN NULL ELSE device_type END"),
]);
});
}
}
Loading