-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
convert activity_log to jsonb + add more index for queries
- Loading branch information
1 parent
0409e87
commit 131a392
Showing
1 changed file
with
20 additions
and
0 deletions.
There are no files selected for viewing
20 changes: 20 additions & 0 deletions
20
database/migrations/2024_11_11_125366_add_index_to_activity_log.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'); | ||
|
||
} | ||
} |