mirror of
https://github.com/ash-project/ash_hq.git
synced 2024-09-20 13:23:38 +12:00
25 lines
572 B
Elixir
25 lines
572 B
Elixir
|
defmodule AshHq.Repo.Migrations.AddTsvectorIndices do
|
||
|
use Ecto.Migration
|
||
|
|
||
|
@config %{
|
||
|
guides: {:name, :text},
|
||
|
library_versions: {:version, :doc},
|
||
|
options: {:name, :doc},
|
||
|
dsls: {:name, :doc}
|
||
|
}
|
||
|
|
||
|
def change do
|
||
|
for {table, {header, text}} <- @config do
|
||
|
execute """
|
||
|
CREATE INDEX #{table}_search_index ON #{table} USING GIN((
|
||
|
setweight(to_tsvector('simple', #{header}), 'A') ||
|
||
|
setweight(to_tsvector('simple', #{text}), 'D')
|
||
|
));
|
||
|
""",
|
||
|
"""
|
||
|
DROP INDEX #{table}_search_index
|
||
|
"""
|
||
|
end
|
||
|
end
|
||
|
end
|