Skip to content

Commit b6367e2

Browse files
committed
Extend profile to work for mysql
Since mysql supports json format now, profile should take that into consideration and generate JSONClient instead of regular one.
1 parent 3b85924 commit b6367e2

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

Diff for: APP_TEMPLATE

+16-2
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,21 @@ class Profile
77
private attr_reader :options, :location
88

99
def client
10-
postgres? ? "RailsEventStore::JSONClient.new" : "RailsEventStore::Client.new"
10+
if postgres? || mysql?
11+
"RailsEventStore::JSONClient.new"
12+
else
13+
"RailsEventStore::Client.new"
14+
end
1115
end
1216

1317
def data_type
14-
postgres? ? "jsonb" : "binary"
18+
if postgres?
19+
"jsonb"
20+
elsif mysql?
21+
"json"
22+
else
23+
"binary"
24+
end
1525
end
1626

1727
def for_existing_app
@@ -24,6 +34,10 @@ class Profile
2434
!!location
2535
end
2636

37+
def mysql?
38+
database.downcase.eql?("mysql2") || database.downcase.eql?("mysql")
39+
end
40+
2741
def postgres?
2842
database.downcase.eql?("postgresql")
2943
end

0 commit comments

Comments
 (0)