Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions lib/ecto/adapters/exqlite.ex
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@ defmodule Ecto.Adapters.Exqlite do
@impl true
def supports_ddl_transaction?(), do: false

@impl true
def lock_for_migrations(_meta, _opts, fun) do
fun.()
end

@impl Ecto.Adapter.Structure
def structure_dump(default, config) do
path = config[:dump_path] || Path.join(default, "structure.sql")
Expand Down
19 changes: 19 additions & 0 deletions lib/ecto/adapters/exqlite/connection.ex
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,29 @@ defmodule Ecto.Adapters.Exqlite.Connection do
import Ecto.Adapters.Exqlite.DataType

@parent_as __MODULE__
@connect_buffer 50

def sleep(opts) do
:timer.sleep(:rand.uniform(@connect_buffer))
opts
end

defp default_opts(opts) do
# todo: we may want to consider wrapping any provided :configure
# with our custom connection buffering logic
opts
|> Keyword.put_new(:configure, {__MODULE__, :sleep, []})
end

def start_link(opts) do
opts = default_opts(opts)
DBConnection.start_link(Exqlite.Connection, opts)
end

@impl true
def child_spec(options) do
{:ok, _} = Application.ensure_all_started(:db_connection)
options = default_opts(options)
DBConnection.child_spec(Exqlite.Connection, options)
end

Expand Down