-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #997 from atlosdotorg/main
Deploy recent changes to `GAP`
- Loading branch information
Showing
1 changed file
with
32 additions
and
0 deletions.
There are no files selected for viewing
32 changes: 32 additions & 0 deletions
32
platform/priv/repo/migrations/20240525003151_move_description_to_text_field.exs
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,32 @@ | ||
defmodule Platform.Repo.Migrations.MoveDescriptionToTextField do | ||
use Ecto.Migration | ||
|
||
def change do | ||
# Drop the 'searchable' column from the 'media' table | ||
execute "ALTER TABLE media DROP COLUMN searchable;" | ||
|
||
alter table(:media) do | ||
modify :attr_description, :text | ||
end | ||
|
||
# Add the 'searchable' column to the 'media' table | ||
execute """ | ||
ALTER TABLE media | ||
ADD COLUMN searchable tsvector | ||
GENERATED ALWAYS AS ( | ||
setweight(to_tsvector('simple', coalesce(slug, '')), 'A') || | ||
setweight(to_tsvector('simple', coalesce(attr_description, '')), 'A') || | ||
setweight(to_tsvector('simple', coalesce(attr_more_info, '')), 'B') || | ||
setweight(to_tsvector('simple', coalesce(attr_general_location, '')), 'C') || | ||
setweight(to_tsvector('simple', imm_array_to_string(attr_restrictions, ' ', ' ')), 'C') || | ||
setweight(to_tsvector('simple', imm_array_to_string(attr_sensitive, ' ', ' ')), 'C') || | ||
setweight(to_tsvector('simple', coalesce(attr_status, '')), 'C') || | ||
setweight(jsonb_to_tsvector('simple', coalesce(auto_metadata, '{}'), '"string"'), 'D') | ||
) STORED | ||
""", | ||
"" | ||
|
||
# Add an index to the 'media' table on searchable | ||
create index(:media, ["searchable"], using: "GIN") | ||
end | ||
end |