-
Notifications
You must be signed in to change notification settings - Fork 71
Expand file tree
/
Copy pathstorage.ex
More file actions
43 lines (36 loc) · 921 Bytes
/
storage.ex
File metadata and controls
43 lines (36 loc) · 921 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
defmodule Conduit.Storage do
@doc """
Reset the event store and read store databases.
"""
def reset! do
:ok = Application.stop(:conduit)
reset_eventstore!()
reset_readstore!()
{:ok, _} = Application.ensure_all_started(:conduit)
end
defp reset_eventstore! do
{:ok, conn} =
Conduit.EventStore.config()
|> EventStore.Config.default_postgrex_opts()
|> Postgrex.start_link()
EventStore.Storage.Initializer.reset!(conn)
end
defp reset_readstore! do
{:ok, conn} = Postgrex.start_link(Conduit.Repo.config())
Postgrex.query!(conn, truncate_readstore_tables(), [])
end
defp truncate_readstore_tables do
"""
TRUNCATE TABLE
accounts_users,
blog_articles,
blog_authors,
blog_comments,
blog_favorited_articles,
blog_feed_articles,
blog_tags,
projection_versions
RESTART IDENTITY;
"""
end
end