ecto-migration-search-pg_trgm
· 398 B · Text
Raw
defmodule MyProject.Repo.Migrations.ItemsSearch do
use Ecto.Migration
def up do
execute "CREATE EXTENSION IF NOT EXISTS pg_trgm;"
execute """
CREATE INDEX items_search_index
ON items
USING gin ((name) gin_trgm_ops);
"""
end
def down do
execute """
DROP INDEX IF EXISTS items_search_index;
"""
execute "DROP EXTENSION IF EXISTS pg_trgm;"
end
end
| 1 | defmodule MyProject.Repo.Migrations.ItemsSearch do |
| 2 | use Ecto.Migration |
| 3 | |
| 4 | def up do |
| 5 | execute "CREATE EXTENSION IF NOT EXISTS pg_trgm;" |
| 6 | |
| 7 | execute """ |
| 8 | CREATE INDEX items_search_index |
| 9 | ON items |
| 10 | USING gin ((name) gin_trgm_ops); |
| 11 | """ |
| 12 | end |
| 13 | |
| 14 | def down do |
| 15 | execute """ |
| 16 | DROP INDEX IF EXISTS items_search_index; |
| 17 | """ |
| 18 | |
| 19 | execute "DROP EXTENSION IF EXISTS pg_trgm;" |
| 20 | end |
| 21 | end |