Current section
7 Versions
Jump to
Current section
7 Versions
Compare versions
3
files changed
+24
additions
-33
deletions
| @@ -85,4 +85,4 @@ | |
| 85 85 | {<<"optional">>,true}, |
| 86 86 | {<<"repository">>,<<"hexpm">>}, |
| 87 87 | {<<"requirement">>,<<"~> 1.7">>}]]}. |
| 88 | - {<<"version">>,<<"1.5.4">>}. |
| 88 | + {<<"version">>,<<"1.5.5">>}. |
| @@ -30,43 +30,34 @@ defmodule ExCatalog.Repo do | |
| 30 30 | end |
| 31 31 | |
| 32 32 | defmodule ExCatalog.Repo.Null do |
| 33 | - use GenServer |
| 33 | + use Ecto.Repo, |
| 34 | + otp_app: :ex_catalog, |
| 35 | + adapter: Ecto.Adapters.Postgres, |
| 36 | + pool: Ecto.Adapters.SQL.Sandbox, |
| 37 | + primary_key_type: :uuid |
| 38 | + |
| 39 | + use Ecto.SoftDelete.Repo |
| 40 | + |
| 34 41 | use Paginator |
| 35 42 | |
| 36 | - def child_spec(init) do |
| 37 | - %{ |
| 38 | - id: __MODULE__, |
| 39 | - start: {__MODULE__, :start_link, [init]}, |
| 40 | - restart: :transient, |
| 41 | - type: :worker |
| 42 | - } |
| 43 | + @doc """ |
| 44 | + Dynamically loads the repository url from the |
| 45 | + DATABASE_URL environment variable. |
| 46 | + """ |
| 47 | + def init(arg, nil) do |
| 48 | + init(arg, []) |
| 43 49 | end |
| 44 50 | |
| 45 | - def start_link([]) do |
| 46 | - GenServer.start_link(__MODULE__, [], name: :ex_null_repo) |
| 51 | + def init(_, opts) do |
| 52 | + {:ok, Keyword.put(opts, :url, System.get_env("DATABASE_URL"))} |
| 47 53 | end |
| 48 54 | |
| 49 | - def init(init_arg) do |
| 50 | - {:ok, init_arg} |
| 51 | - end |
| 55 | + @doc """ |
| 56 | + Empty the Database Table |
| 57 | + """ |
| 58 | + def truncate(schema) do |
| 59 | + table_name = schema.__schema__(:source) |
| 52 60 | |
| 53 | - def all(_) do |
| 54 | - [] |
| 55 | - end |
| 56 | - |
| 57 | - def all(_, _) do |
| 58 | - [] |
| 59 | - end |
| 60 | - |
| 61 | - def get_by(_, _) do |
| 62 | - [] |
| 63 | - end |
| 64 | - |
| 65 | - def get_by!(_, _) do |
| 66 | - [] |
| 67 | - end |
| 68 | - |
| 69 | - def one(_, _) do |
| 70 | - [] |
| 61 | + query("TRUNCATE #{table_name}", []) |
| 71 62 | end |
| 72 63 | end |
| @@ -1,7 +1,7 @@ | |
| 1 1 | defmodule ExCatalog.MixProject do |
| 2 2 | use Mix.Project |
| 3 3 | |
| 4 | - @version "1.5.4" |
| 4 | + @version "1.5.5" |
| 5 5 | @source_url "https://github.com/mithereal/ExCatalog" |
| 6 6 | |
| 7 7 | def project do |