-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Giovanni Visciano
committed
Aug 13, 2021
1 parent
225fb1d
commit f021321
Showing
10 changed files
with
99 additions
and
18 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
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,36 @@ | ||
# coveralls-ignore-start | ||
|
||
defmodule ExqlMigration.CreateDB do | ||
@moduledoc "Migration runner Supervisor" | ||
|
||
use Supervisor | ||
|
||
require Logger | ||
|
||
@type opts :: [{:db_conn, Postgrex.conn()} | {:db_name, String.t()}] | ||
|
||
@spec start_link(opts()) :: Supervisor.on_start() | ||
def start_link(opts) do | ||
db_conn = Keyword.fetch!(opts, :db_conn) | ||
db_name = Keyword.fetch!(opts, :db_name) | ||
|
||
Supervisor.start_link(__MODULE__, {db_conn, db_name}) | ||
end | ||
|
||
@impl Supervisor | ||
@spec init({Postgrex.conn(), String.t()}) :: :ignore | ||
def init({db_conn, db_name}) do | ||
ExqlMigration.create_db(db_conn, db_name) | ||
|
||
:ignore | ||
rescue | ||
exc -> | ||
Logger.emergency("Create DB failed") | ||
Logger.emergency(Exception.message(exc)) | ||
Logger.emergency("#{inspect(exc)}") | ||
|
||
:init.stop() | ||
end | ||
end | ||
|
||
# coveralls-ignore-stop |
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,7 @@ | ||
import Config | ||
|
||
config :example, :db_postgres, name: :db_postgres | ||
|
||
config :example, :db_mydb, | ||
name: :db_mydb, | ||
migration_dir: "priv/migrations/mydb" |
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 |
---|---|---|
@@ -1,12 +1,15 @@ | ||
import Config | ||
|
||
config :postgrex, | ||
name: :db, | ||
config :example, :db_postgres, | ||
hostname: "localhost", | ||
username: "postgres", | ||
password: "postgres", | ||
database: "postgres", | ||
pool_size: 5 | ||
pool_size: 1 | ||
|
||
config :exql_migration, | ||
migration_dir: "priv/migrations" | ||
config :example, :db_mydb, | ||
hostname: "localhost", | ||
username: "postgres", | ||
password: "postgres", | ||
database: "mydb", | ||
pool_size: 5 |
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 was deleted.
Oops, something went wrong.
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 @@ | ||
perform 1; |
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