add pack lot number to search
Some checks failed
continuous-integration/drone/push Build is failing

This commit is contained in:
shibao 2023-04-14 23:38:06 -04:00
parent 1037f37be2
commit 334d841d57
2 changed files with 35 additions and 0 deletions

View File

@ -1,5 +1,6 @@
# v0.9.3
- Update dependencies
- Add pack lot number to search
# v0.9.2
- Add lot number to packs

View File

@ -0,0 +1,34 @@
defmodule Cannery.Repo.Migrations.AddPackLotNumberToSearch do
use Ecto.Migration
def up do
execute "ALTER TABLE packs DROP COLUMN search"
execute """
ALTER TABLE packs
ADD COLUMN search tsvector
GENERATED ALWAYS AS (
setweight(to_tsvector('english', coalesce("notes", '')), 'A') ||
setweight(to_tsvector('english', coalesce("lot_number", '')), 'A') ||
setweight(to_tsvector('english', immutable_to_string("price_paid", '')), 'B') ||
setweight(to_tsvector('english', immutable_to_string("purchased_on", '')), 'B') ||
setweight(to_tsvector('english', immutable_to_string("count", '')), 'C')
) STORED
"""
end
def down do
execute "ALTER TABLE packs DROP COLUMN search"
execute """
ALTER TABLE packs
ADD COLUMN search tsvector
GENERATED ALWAYS AS (
setweight(to_tsvector('english', coalesce("notes", '')), 'A') ||
setweight(to_tsvector('english', immutable_to_string("price_paid", '')), 'B') ||
setweight(to_tsvector('english', immutable_to_string("purchased_on", '')), 'B') ||
setweight(to_tsvector('english', immutable_to_string("count", '')), 'C')
) STORED
"""
end
end