Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extend profile to work for mysql #1575

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 18 additions & 8 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?
%w[mysql2 mysql trilogy].include?(database.downcase)
end

def postgres?
database.downcase.eql?("postgresql")
end
Expand Down Expand Up @@ -71,16 +85,12 @@ CODE

route "mount RailsEventStore::Browser => '/res' if Rails.env.development?"

profile.for_existing_app do
run_bundle unless run "bundle check"
end
profile.for_existing_app { run_bundle unless run "bundle check" }

after_bundle do
rails_command "db:create"
generate "rails_event_store_active_record:migration --data-type=#{profile.data_type}"
rails_command "db:migrate"
end

profile.for_existing_app do
run_after_bundle_callbacks
end
profile.for_existing_app { run_after_bundle_callbacks }