Skip to content

Commit

Permalink
Create the permanent database on startup if needed
Browse files Browse the repository at this point in the history
  • Loading branch information
nkezhaya committed Oct 15, 2020
1 parent 90a6a9e commit 8b6f02b
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion lib/stripe_mock/database.ex
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,21 @@ defmodule StripeMock.Database do
{:ok, config}
end

def init(_) do
def init(false) do
# Create the permanent database
config = Application.get_env(:stripe_mock, StripeMock.Repo)

case Ecto.Adapters.Postgres.storage_up(config) do
:ok ->
nil

{:error, :already_up} ->
nil

{:error, term} ->
raise "The database couldn't be created: #{inspect(term)}"
end

{:ok, []}
end

Expand Down

0 comments on commit 8b6f02b

Please sign in to comment.