-
Notifications
You must be signed in to change notification settings - Fork 15
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 #35 from curiosum-dev/release/0.3.0
Release/0.3.0
- Loading branch information
Showing
19 changed files
with
233 additions
and
83 deletions.
There are no files selected for viewing
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 |
---|---|---|
|
@@ -102,7 +102,7 @@ by adding `kanta` to your list of dependencies in `mix.exs`: | |
```elixir | ||
def deps do | ||
[ | ||
{:kanta, "~> 0.2.2"}, | ||
{:kanta, "~> 0.3.0"}, | ||
{:gettext, git: "[email protected]:ravensiris/gettext.git", branch: "runtime-gettext"} | ||
] | ||
end | ||
|
@@ -140,11 +140,11 @@ defmodule MyApp.Repo.Migrations.AddKantaTranslationsTable do | |
use Ecto.Migration | ||
|
||
def up do | ||
Kanta.Migration.up(version: 1, prefix: prefix()) # Prefix is needed if you are using multitenancy with i.e. triplex | ||
Kanta.Migration.up(version: 2, prefix: prefix()) # Prefix is needed if you are using multitenancy with i.e. triplex | ||
end | ||
|
||
def down do | ||
Kanta.Migration.down(version: 1, prefix: prefix()) # Prefix is needed if you are using multitenancy with i.e. triplex | ||
Kanta.Migration.down(version: 2, prefix: prefix()) # Prefix is needed if you are using multitenancy with i.e. triplex | ||
end | ||
end | ||
``` | ||
|
@@ -183,6 +183,8 @@ In the `application.ex` file of our project, we add Kanta and its configuration | |
Inside your `router.ex` file we need to connect the Kanta panel using the kanta_dashboard macro. | ||
|
||
```elixir | ||
import KantaWeb.Router | ||
|
||
scope "/" do | ||
pipe_through :browser | ||
|
||
|
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
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
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
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,46 @@ | ||
defmodule Kanta.Migrations.Postgresql.V02 do | ||
@moduledoc """ | ||
Kanta V2 Migrations | ||
""" | ||
|
||
use Ecto.Migration | ||
|
||
@default_prefix "public" | ||
@kanta_singular_translations "kanta_singular_translations" | ||
@kanta_plural_translations "kanta_plural_translations" | ||
|
||
def up(opts) do | ||
Kanta.Migration.up(version: 1) | ||
up_fuzzy_search(opts) | ||
end | ||
|
||
def down(opts) do | ||
down_fuzzy_search(opts) | ||
Kanta.Migration.down(version: 1) | ||
end | ||
|
||
def up_fuzzy_search(opts) do | ||
prefix = Map.get(opts, :prefix, @default_prefix) | ||
|
||
[@kanta_plural_translations, @kanta_singular_translations] | ||
|> Enum.each(fn table_name -> | ||
execute """ | ||
ALTER TABLE #{prefix}.#{table_name} | ||
ADD COLUMN IF NOT EXISTS searchable tsvector | ||
GENERATED ALWAYS AS ( | ||
setweight(to_tsvector('simple', coalesce(translated_text, '')), 'A') | ||
) STORED; | ||
""" | ||
|
||
execute """ | ||
CREATE INDEX IF NOT EXISTS #{table_name}_searchable_idx ON #{prefix}.#{table_name} USING gin(searchable); | ||
""" | ||
end) | ||
|
||
execute("CREATE EXTENSION IF NOT EXISTS unaccent;") | ||
end | ||
|
||
def down_fuzzy_search(_opts) do | ||
execute("DROP EXTENSION IF EXISTS unaccent;") | ||
end | ||
end |
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
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
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
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
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
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
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
Oops, something went wrong.