Skip to content

Commit

Permalink
Extend profile to work for mysql
Browse files Browse the repository at this point in the history
Since mysql supports json format now, profile should take that into
consideration and generate JSONClient instead of regular one.
  • Loading branch information
lukaszreszke committed Feb 7, 2023
1 parent 3b85924 commit b6367e2
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions APP_TEMPLATE
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,21 @@ class Profile
private attr_reader :options, :location

def client
postgres? ? "RailsEventStore::JSONClient.new" : "RailsEventStore::Client.new"
if postgres? || mysql?
"RailsEventStore::JSONClient.new"
else
"RailsEventStore::Client.new"
end
end

def data_type
postgres? ? "jsonb" : "binary"
if postgres?
"jsonb"
elsif mysql?
"json"
else
"binary"
end
end

def for_existing_app
Expand All @@ -24,6 +34,10 @@ class Profile
!!location
end

def mysql?
database.downcase.eql?("mysql2") || database.downcase.eql?("mysql")
end

def postgres?
database.downcase.eql?("postgresql")
end
Expand Down

0 comments on commit b6367e2

Please sign in to comment.