From 94a75c9e001c83b7652fdd822aa784874036f0de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Reszke?= Date: Tue, 7 Feb 2023 12:52:53 +0100 Subject: [PATCH 1/3] 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. --- APP_TEMPLATE | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/APP_TEMPLATE b/APP_TEMPLATE index f16e115cbd..891fd3a498 100644 --- a/APP_TEMPLATE +++ b/APP_TEMPLATE @@ -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 @@ -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 From 326700051e8f588ae19bdb42a3e811e3f5c938df Mon Sep 17 00:00:00 2001 From: Szymon Fiedler Date: Mon, 9 Oct 2023 17:49:30 +0200 Subject: [PATCH 2/3] Trilogy is also MySQL adapter --- APP_TEMPLATE | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/APP_TEMPLATE b/APP_TEMPLATE index 891fd3a498..38464e3e1a 100644 --- a/APP_TEMPLATE +++ b/APP_TEMPLATE @@ -35,7 +35,7 @@ class Profile end def mysql? - database.downcase.eql?("mysql2") || database.downcase.eql?("mysql") + %w[mysql2 mysql trilogy].include?(database.downcase) end def postgres? @@ -97,4 +97,4 @@ end profile.for_existing_app do run_after_bundle_callbacks -end \ No newline at end of file +end From 9873ded98376bb9695d1f8e05416a8b5d0aa3329 Mon Sep 17 00:00:00 2001 From: Szymon Fiedler Date: Mon, 9 Oct 2023 17:51:37 +0200 Subject: [PATCH 3/3] Formatting --- APP_TEMPLATE | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/APP_TEMPLATE b/APP_TEMPLATE index 38464e3e1a..5ffbeb40b1 100644 --- a/APP_TEMPLATE +++ b/APP_TEMPLATE @@ -85,9 +85,7 @@ 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" @@ -95,6 +93,4 @@ after_bundle do rails_command "db:migrate" end -profile.for_existing_app do - run_after_bundle_callbacks -end +profile.for_existing_app { run_after_bundle_callbacks }