add search to notes
This commit is contained in:
@ -75,7 +75,7 @@ msgid "create invite"
|
||||
msgstr ""
|
||||
|
||||
#: lib/memex_web/live/context_live/index.html.heex:53
|
||||
#: lib/memex_web/live/note_live/index.html.heex:32
|
||||
#: lib/memex_web/live/note_live/index.html.heex:43
|
||||
#: lib/memex_web/live/pipeline_live/index.html.heex:51
|
||||
#, elixir-autogen, elixir-format
|
||||
msgid "delete"
|
||||
@ -88,7 +88,7 @@ msgstr ""
|
||||
|
||||
#: lib/memex_web/live/context_live/index.html.heex:43
|
||||
#: lib/memex_web/live/context_live/show.html.heex:40
|
||||
#: lib/memex_web/live/note_live/index.html.heex:23
|
||||
#: lib/memex_web/live/note_live/index.html.heex:34
|
||||
#: lib/memex_web/live/note_live/show.html.heex:27
|
||||
#: lib/memex_web/live/pipeline_live/index.html.heex:41
|
||||
#: lib/memex_web/live/pipeline_live/show.html.heex:35
|
||||
@ -117,7 +117,7 @@ msgstr ""
|
||||
msgid "new context"
|
||||
msgstr ""
|
||||
|
||||
#: lib/memex_web/live/note_live/index.html.heex:41
|
||||
#: lib/memex_web/live/note_live/index.html.heex:52
|
||||
#, elixir-autogen, elixir-format
|
||||
msgid "new note"
|
||||
msgstr ""
|
||||
|
@ -15,7 +15,7 @@ msgstr ""
|
||||
msgid "%{title} created"
|
||||
msgstr ""
|
||||
|
||||
#: lib/memex_web/live/note_live/index.ex:48
|
||||
#: lib/memex_web/live/note_live/index.ex:57
|
||||
#, elixir-autogen, elixir-format
|
||||
msgid "%{title} deleted"
|
||||
msgstr ""
|
||||
@ -167,7 +167,7 @@ msgstr ""
|
||||
msgid "document your processes, attaching contexts to each step"
|
||||
msgstr ""
|
||||
|
||||
#: lib/memex_web/live/note_live/index.ex:24
|
||||
#: lib/memex_web/live/note_live/index.ex:23
|
||||
#, elixir-autogen, elixir-format
|
||||
msgid "edit %{title}"
|
||||
msgstr ""
|
||||
@ -267,7 +267,7 @@ msgstr ""
|
||||
msgid "no invites 😔"
|
||||
msgstr ""
|
||||
|
||||
#: lib/memex_web/live/note_live/index.html.heex:8
|
||||
#: lib/memex_web/live/note_live/index.html.heex:19
|
||||
#, elixir-autogen, elixir-format
|
||||
msgid "no notes found"
|
||||
msgstr ""
|
||||
|
@ -142,7 +142,7 @@ msgid "are you sure you want to make %{invite_name} unlimited?"
|
||||
msgstr ""
|
||||
|
||||
#: lib/memex_web/live/context_live/index.html.heex:51
|
||||
#: lib/memex_web/live/note_live/index.html.heex:29
|
||||
#: lib/memex_web/live/note_live/index.html.heex:40
|
||||
#: lib/memex_web/live/pipeline_live/index.html.heex:49
|
||||
#, elixir-autogen, elixir-format
|
||||
msgid "are you sure?"
|
||||
|
@ -1,17 +1,41 @@
|
||||
defmodule Memex.Repo.Migrations.CreateNotes do
|
||||
use Ecto.Migration
|
||||
|
||||
def change do
|
||||
def up do
|
||||
create table(:notes, primary_key: false) do
|
||||
add :id, :binary_id, primary_key: true
|
||||
add :title, :string
|
||||
add :content, :text
|
||||
add :tags, {:array, :string}
|
||||
add :tags, {:array, :citext}
|
||||
add :visibility, :string
|
||||
|
||||
add :user_id, references(:users, on_delete: :delete_all, type: :binary_id)
|
||||
|
||||
timestamps()
|
||||
end
|
||||
|
||||
flush()
|
||||
|
||||
execute """
|
||||
CREATE FUNCTION immutable_array_to_string(text[], text)
|
||||
RETURNS text LANGUAGE sql IMMUTABLE as $$SELECT array_to_string($1, $2)$$
|
||||
"""
|
||||
|
||||
execute """
|
||||
ALTER TABLE notes
|
||||
ADD COLUMN search tsvector
|
||||
GENERATED ALWAYS AS (
|
||||
setweight(to_tsvector('english', coalesce(title, '')), 'A') ||
|
||||
setweight(to_tsvector('english', coalesce(immutable_array_to_string(tags, ' '), '')), 'B') ||
|
||||
setweight(to_tsvector('english', coalesce(content, '')), 'C')
|
||||
) STORED
|
||||
"""
|
||||
|
||||
execute("CREATE INDEX notes_trgm_idx ON notes USING GIN (search)")
|
||||
end
|
||||
|
||||
def down do
|
||||
drop table(:notes)
|
||||
execute("DROP FUNCTION immutable_array_to_string(text[], text)")
|
||||
end
|
||||
end
|
||||
|
Reference in New Issue
Block a user