Move SQLite extension loading to config/runtime.exs
Addresses deprecation mentioned at https://hexdocs.pm/ecto/Ecto.Repo.html#c:init/2
This commit is contained in:
@@ -28,6 +28,11 @@ if user = System.get_env("LAST_FM_USER") do
|
|||||||
config :music_library, LastFm, user: user
|
config :music_library, LastFm, user: user
|
||||||
end
|
end
|
||||||
|
|
||||||
|
config :music_library, MusicLibrary.Repo,
|
||||||
|
load_extensions: [
|
||||||
|
MusicLibrary.Repo.extension_path("unicode")
|
||||||
|
]
|
||||||
|
|
||||||
if config_env() == :prod do
|
if config_env() == :prod do
|
||||||
database_path =
|
database_path =
|
||||||
System.get_env("DATABASE_PATH") ||
|
System.get_env("DATABASE_PATH") ||
|
||||||
|
|||||||
@@ -3,13 +3,6 @@ defmodule MusicLibrary.Repo do
|
|||||||
otp_app: :music_library,
|
otp_app: :music_library,
|
||||||
adapter: Ecto.Adapters.SQLite3
|
adapter: Ecto.Adapters.SQLite3
|
||||||
|
|
||||||
def init(_context, config) do
|
|
||||||
{:ok,
|
|
||||||
Keyword.put(config, :load_extensions, [
|
|
||||||
extension_path("unicode")
|
|
||||||
])}
|
|
||||||
end
|
|
||||||
|
|
||||||
def extension_path(name) do
|
def extension_path(name) do
|
||||||
[arch | _rest] =
|
[arch | _rest] =
|
||||||
:erlang.system_info(:system_architecture)
|
:erlang.system_info(:system_architecture)
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
defmodule MusicLibrary.RepoTest do
|
defmodule MusicLibrary.RepoTest do
|
||||||
alias MusicLibrary.ReleaseGroupsFixtures
|
|
||||||
use MusicLibrary.DataCase
|
use MusicLibrary.DataCase
|
||||||
|
|
||||||
describe "correctly loads the unicode extension" do
|
describe "correctly loads the unicode extension" do
|
||||||
|
|||||||
Reference in New Issue
Block a user