Skip to content

Commit

Permalink
convert activity_log to jsonb + add more index for queries
Browse files Browse the repository at this point in the history
  • Loading branch information
andrasbacsai committed Nov 20, 2024
1 parent 0409e87 commit 131a392
Showing 1 changed file with 20 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php

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

class AddIndexToActivityLog extends Migration
{
public function up()
{
DB::statement('ALTER TABLE activity_log ALTER COLUMN properties TYPE jsonb USING properties::jsonb');
DB::statement('CREATE INDEX idx_activity_type_uuid ON activity_log USING GIN (properties jsonb_path_ops)');
}

public function down()
{
DB::statement('DROP INDEX IF EXISTS idx_activity_type_uuid');
DB::statement('ALTER TABLE activity_log ALTER COLUMN properties TYPE json USING properties::json');

}
}

0 comments on commit 131a392

Please sign in to comment.