File tree Expand file tree Collapse file tree 1 file changed +19
-2
lines changed Expand file tree Collapse file tree 1 file changed +19
-2
lines changed Original file line number Diff line number Diff line change @@ -7,7 +7,16 @@ defmodule ClickhouseEcto.Storage do
7
7
8
8
opts = Keyword . put ( opts , :database , nil )
9
9
10
- command = ~s[ CREATE DATABASE IF NOT EXISTS "#{ database } "]
10
+ cluster = Keyword . get ( opts , :cluster )
11
+
12
+ opts = Keyword . put ( opts , :database , nil )
13
+
14
+ command =
15
+ if is_nil ( cluster ) do
16
+ ~s[ CREATE DATABASE IF NOT EXISTS "#{ database } "]
17
+ else
18
+ ~s[ CREATE DATABASE IF NOT EXISTS "#{ database } " ON CLUSTER '#{ cluster } ']
19
+ end
11
20
12
21
case run_query ( command , opts ) do
13
22
{ :ok , _ } ->
@@ -26,7 +35,15 @@ defmodule ClickhouseEcto.Storage do
26
35
database =
27
36
Keyword . fetch! ( opts , :database ) || raise ":database is nil in repository configuration"
28
37
29
- command = ~s[ DROP DATABASE "#{ database } "]
38
+ cluster = Keyword . get ( opts , :cluster )
39
+
40
+ command =
41
+ if is_nil ( cluster ) do
42
+ ~s[ DROP DATABASE "#{ database } "]
43
+ else
44
+ ~s[ DROP DATABASE "#{ database } " ON CLUSTER '#{ cluster } ']
45
+ end
46
+
30
47
opts = Keyword . put ( opts , :database , nil )
31
48
32
49
case run_query ( command , opts ) do
You can’t perform that action at this time.
0 commit comments