From 1fa8c99afa9a7268a7ad3b95bcd3aa02889866d1 Mon Sep 17 00:00:00 2001 From: Amogh Shetkar Date: Tue, 25 Jun 2024 17:45:42 +0000 Subject: [PATCH 1/3] Use YugabyteDB Ruby Smart driver and its ActiveRecord Adapter --- ruby/ror/Gemfile | 5 +- ruby/ror/Gemfile.lock | 189 +++++++++++++++++++++++++++++++++++ ruby/ror/config/database.yml | 4 +- 3 files changed, 194 insertions(+), 4 deletions(-) create mode 100644 ruby/ror/Gemfile.lock diff --git a/ruby/ror/Gemfile b/ruby/ror/Gemfile index e072513..b800b46 100644 --- a/ruby/ror/Gemfile +++ b/ruby/ror/Gemfile @@ -1,9 +1,10 @@ source 'https://rubygems.org' git_source(:github) { |repo| "https://github.com/#{repo}.git" } -gem 'rails', '~> 7.0.4' +gem 'rails', '7.0.4' +gem 'activerecord-yugabytedb-adapter', '7.0.4.1' gem 'sprockets-rails', '~> 3.0.0' -gem 'pg', '~> 1.4.4' +gem 'yugabyte_ysql', '~> 0.3' gem 'puma', '~> 5.6.5' gem 'bootsnap', '>= 1.1.0', require: false group :development, :test do diff --git a/ruby/ror/Gemfile.lock b/ruby/ror/Gemfile.lock new file mode 100644 index 0000000..b0a8838 --- /dev/null +++ b/ruby/ror/Gemfile.lock @@ -0,0 +1,189 @@ +GEM + remote: https://rubygems.org/ + specs: + actioncable (7.0.4) + actionpack (= 7.0.4) + activesupport (= 7.0.4) + nio4r (~> 2.0) + websocket-driver (>= 0.6.1) + actionmailbox (7.0.4) + actionpack (= 7.0.4) + activejob (= 7.0.4) + activerecord (= 7.0.4) + activestorage (= 7.0.4) + activesupport (= 7.0.4) + mail (>= 2.7.1) + net-imap + net-pop + net-smtp + actionmailer (7.0.4) + actionpack (= 7.0.4) + actionview (= 7.0.4) + activejob (= 7.0.4) + activesupport (= 7.0.4) + mail (~> 2.5, >= 2.5.4) + net-imap + net-pop + net-smtp + rails-dom-testing (~> 2.0) + actionpack (7.0.4) + actionview (= 7.0.4) + activesupport (= 7.0.4) + rack (~> 2.0, >= 2.2.0) + rack-test (>= 0.6.3) + rails-dom-testing (~> 2.0) + rails-html-sanitizer (~> 1.0, >= 1.2.0) + actiontext (7.0.4) + actionpack (= 7.0.4) + activerecord (= 7.0.4) + activestorage (= 7.0.4) + activesupport (= 7.0.4) + globalid (>= 0.6.0) + nokogiri (>= 1.8.5) + actionview (7.0.4) + activesupport (= 7.0.4) + builder (~> 3.1) + erubi (~> 1.4) + rails-dom-testing (~> 2.0) + rails-html-sanitizer (~> 1.1, >= 1.2.0) + activejob (7.0.4) + activesupport (= 7.0.4) + globalid (>= 0.3.6) + activemodel (7.0.4) + activesupport (= 7.0.4) + activerecord (7.0.4) + activemodel (= 7.0.4) + activesupport (= 7.0.4) + activerecord-yugabytedb-adapter (7.0.4.1) + activerecord (= 7.0.4) + yugabyte_ysql (~> 0.3) + activestorage (7.0.4) + actionpack (= 7.0.4) + activejob (= 7.0.4) + activerecord (= 7.0.4) + activesupport (= 7.0.4) + marcel (~> 1.0) + mini_mime (>= 1.1.0) + activesupport (7.0.4) + concurrent-ruby (~> 1.0, >= 1.0.2) + i18n (>= 1.6, < 2) + minitest (>= 5.1) + tzinfo (~> 2.0) + bootsnap (1.18.3) + msgpack (~> 1.2) + builder (3.3.0) + byebug (11.1.3) + concurrent-ruby (1.3.1) + crass (1.0.6) + date (3.3.4) + erubi (1.12.0) + ffi (1.17.0-x86_64-linux-gnu) + globalid (1.2.1) + activesupport (>= 6.1) + i18n (1.14.5) + concurrent-ruby (~> 1.0) + listen (3.7.1) + rb-fsevent (~> 0.10, >= 0.10.3) + rb-inotify (~> 0.9, >= 0.9.10) + loofah (2.22.0) + crass (~> 1.0.2) + nokogiri (>= 1.12.0) + mail (2.8.1) + mini_mime (>= 0.1.1) + net-imap + net-pop + net-smtp + marcel (1.0.4) + method_source (1.1.0) + mini_mime (1.1.5) + minitest (5.23.1) + msgpack (1.7.2) + net-imap (0.4.13) + date + net-protocol + net-pop (0.1.2) + net-protocol + net-protocol (0.2.2) + timeout + net-smtp (0.5.0) + net-protocol + nio4r (2.7.3) + nokogiri (1.16.5-x86_64-linux) + racc (~> 1.4) + puma (5.6.8) + nio4r (~> 2.0) + racc (1.8.0) + rack (2.2.9) + rack-test (2.1.0) + rack (>= 1.3) + rails (7.0.4) + actioncable (= 7.0.4) + actionmailbox (= 7.0.4) + actionmailer (= 7.0.4) + actionpack (= 7.0.4) + actiontext (= 7.0.4) + actionview (= 7.0.4) + activejob (= 7.0.4) + activemodel (= 7.0.4) + activerecord (= 7.0.4) + activestorage (= 7.0.4) + activesupport (= 7.0.4) + bundler (>= 1.15.0) + railties (= 7.0.4) + rails-dom-testing (2.2.0) + activesupport (>= 5.0.0) + minitest + nokogiri (>= 1.6) + rails-html-sanitizer (1.6.0) + loofah (~> 2.21) + nokogiri (~> 1.14) + railties (7.0.4) + actionpack (= 7.0.4) + activesupport (= 7.0.4) + method_source + rake (>= 12.2) + thor (~> 1.0) + zeitwerk (~> 2.5) + rake (13.2.1) + rb-fsevent (0.11.2) + rb-inotify (0.11.1) + ffi (~> 1.0) + spring (4.2.1) + spring-watcher-listen (2.1.0) + listen (>= 2.7, < 4.0) + spring (>= 4) + sprockets (4.2.1) + concurrent-ruby (~> 1.0) + rack (>= 2.2.4, < 4) + sprockets-rails (3.0.4) + actionpack (>= 4.0) + activesupport (>= 4.0) + sprockets (>= 3.0.0) + thor (1.3.1) + timeout (0.4.1) + tzinfo (2.0.6) + concurrent-ruby (~> 1.0) + websocket-driver (0.7.6) + websocket-extensions (>= 0.1.0) + websocket-extensions (0.1.5) + yugabyte_ysql (0.3) + zeitwerk (2.6.16) + +PLATFORMS + x86_64-linux + +DEPENDENCIES + activerecord-yugabytedb-adapter (= 7.0.4.1) + bootsnap (>= 1.1.0) + byebug + listen (~> 3.7.1) + puma (~> 5.6.5) + rails (= 7.0.4) + spring + spring-watcher-listen (~> 2.1.0) + sprockets-rails (~> 3.0.0) + tzinfo-data + yugabyte_ysql (~> 0.3) + +BUNDLED WITH + 2.3.27 diff --git a/ruby/ror/config/database.yml b/ruby/ror/config/database.yml index bb3908b..420ad56 100644 --- a/ruby/ror/config/database.yml +++ b/ruby/ror/config/database.yml @@ -1,13 +1,13 @@ default: &default - adapter: postgresql + adapter: yugabytedb encoding: unicode pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %> development: <<: *default database: ysql_active_record - username: postgres + username: yugabyte password: host: 127.0.0.1 port: 5433 From 372c6efe7f212197094bbc7af141c4dcb4c95f26 Mon Sep 17 00:00:00 2001 From: Amogh Shetkar Date: Wed, 3 Jul 2024 05:34:04 +0000 Subject: [PATCH 2/3] Update rails, driver and adapter version --- ruby/ror/Gemfile | 6 +++--- ruby/ror/config/database.yml | 1 + ruby/ror/db/schema.rb | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/ruby/ror/Gemfile b/ruby/ror/Gemfile index b800b46..abe27e8 100644 --- a/ruby/ror/Gemfile +++ b/ruby/ror/Gemfile @@ -1,10 +1,10 @@ source 'https://rubygems.org' git_source(:github) { |repo| "https://github.com/#{repo}.git" } -gem 'rails', '7.0.4' -gem 'activerecord-yugabytedb-adapter', '7.0.4.1' +gem 'rails', '7.1.3.4' +gem 'activerecord-yugabytedb-adapter', '~> 7.1.3.4' gem 'sprockets-rails', '~> 3.0.0' -gem 'yugabyte_ysql', '~> 0.3' +gem 'yugabytedb-ysql', '~> 0.3' gem 'puma', '~> 5.6.5' gem 'bootsnap', '>= 1.1.0', require: false group :development, :test do diff --git a/ruby/ror/config/database.yml b/ruby/ror/config/database.yml index 420ad56..fdc8f66 100644 --- a/ruby/ror/config/database.yml +++ b/ruby/ror/config/database.yml @@ -11,6 +11,7 @@ development: password: host: 127.0.0.1 port: 5433 + load_balance: true production: <<: *default diff --git a/ruby/ror/db/schema.rb b/ruby/ror/db/schema.rb index 2a4691e..6b50273 100644 --- a/ruby/ror/db/schema.rb +++ b/ruby/ror/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema[7.0].define(version: 2019_05_04_204851) do +ActiveRecord::Schema[7.1].define(version: 2019_05_04_204851) do # These are extensions that must be enabled in order to support this database enable_extension "pg_stat_statements" enable_extension "plpgsql" From b94bdf2da8499e4b168126b2de92ee4f3c67b950 Mon Sep 17 00:00:00 2001 From: Amogh Shetkar Date: Fri, 2 Aug 2024 09:30:40 +0000 Subject: [PATCH 3/3] Use yugabytedb-ysql gem version which coexists with pg gem --- ruby/ror/Gemfile | 3 +- ruby/ror/Gemfile.lock | 181 +++++++++++++++++++++++++----------------- 2 files changed, 109 insertions(+), 75 deletions(-) diff --git a/ruby/ror/Gemfile b/ruby/ror/Gemfile index abe27e8..86ced90 100644 --- a/ruby/ror/Gemfile +++ b/ruby/ror/Gemfile @@ -4,7 +4,8 @@ git_source(:github) { |repo| "https://github.com/#{repo}.git" } gem 'rails', '7.1.3.4' gem 'activerecord-yugabytedb-adapter', '~> 7.1.3.4' gem 'sprockets-rails', '~> 3.0.0' -gem 'yugabytedb-ysql', '~> 0.3' +gem 'pg', '~> 1.4.4' +gem 'yugabytedb-ysql', '~> 0.4' gem 'puma', '~> 5.6.5' gem 'bootsnap', '>= 1.1.0', require: false group :development, :test do diff --git a/ruby/ror/Gemfile.lock b/ruby/ror/Gemfile.lock index b0a8838..b2a3cc6 100644 --- a/ruby/ror/Gemfile.lock +++ b/ruby/ror/Gemfile.lock @@ -1,87 +1,104 @@ GEM remote: https://rubygems.org/ specs: - actioncable (7.0.4) - actionpack (= 7.0.4) - activesupport (= 7.0.4) + actioncable (7.1.3.4) + actionpack (= 7.1.3.4) + activesupport (= 7.1.3.4) nio4r (~> 2.0) websocket-driver (>= 0.6.1) - actionmailbox (7.0.4) - actionpack (= 7.0.4) - activejob (= 7.0.4) - activerecord (= 7.0.4) - activestorage (= 7.0.4) - activesupport (= 7.0.4) + zeitwerk (~> 2.6) + actionmailbox (7.1.3.4) + actionpack (= 7.1.3.4) + activejob (= 7.1.3.4) + activerecord (= 7.1.3.4) + activestorage (= 7.1.3.4) + activesupport (= 7.1.3.4) mail (>= 2.7.1) net-imap net-pop net-smtp - actionmailer (7.0.4) - actionpack (= 7.0.4) - actionview (= 7.0.4) - activejob (= 7.0.4) - activesupport (= 7.0.4) + actionmailer (7.1.3.4) + actionpack (= 7.1.3.4) + actionview (= 7.1.3.4) + activejob (= 7.1.3.4) + activesupport (= 7.1.3.4) mail (~> 2.5, >= 2.5.4) net-imap net-pop net-smtp - rails-dom-testing (~> 2.0) - actionpack (7.0.4) - actionview (= 7.0.4) - activesupport (= 7.0.4) - rack (~> 2.0, >= 2.2.0) + rails-dom-testing (~> 2.2) + actionpack (7.1.3.4) + actionview (= 7.1.3.4) + activesupport (= 7.1.3.4) + nokogiri (>= 1.8.5) + racc + rack (>= 2.2.4) + rack-session (>= 1.0.1) rack-test (>= 0.6.3) - rails-dom-testing (~> 2.0) - rails-html-sanitizer (~> 1.0, >= 1.2.0) - actiontext (7.0.4) - actionpack (= 7.0.4) - activerecord (= 7.0.4) - activestorage (= 7.0.4) - activesupport (= 7.0.4) + rails-dom-testing (~> 2.2) + rails-html-sanitizer (~> 1.6) + actiontext (7.1.3.4) + actionpack (= 7.1.3.4) + activerecord (= 7.1.3.4) + activestorage (= 7.1.3.4) + activesupport (= 7.1.3.4) globalid (>= 0.6.0) nokogiri (>= 1.8.5) - actionview (7.0.4) - activesupport (= 7.0.4) + actionview (7.1.3.4) + activesupport (= 7.1.3.4) builder (~> 3.1) - erubi (~> 1.4) - rails-dom-testing (~> 2.0) - rails-html-sanitizer (~> 1.1, >= 1.2.0) - activejob (7.0.4) - activesupport (= 7.0.4) + erubi (~> 1.11) + rails-dom-testing (~> 2.2) + rails-html-sanitizer (~> 1.6) + activejob (7.1.3.4) + activesupport (= 7.1.3.4) globalid (>= 0.3.6) - activemodel (7.0.4) - activesupport (= 7.0.4) - activerecord (7.0.4) - activemodel (= 7.0.4) - activesupport (= 7.0.4) - activerecord-yugabytedb-adapter (7.0.4.1) - activerecord (= 7.0.4) - yugabyte_ysql (~> 0.3) - activestorage (7.0.4) - actionpack (= 7.0.4) - activejob (= 7.0.4) - activerecord (= 7.0.4) - activesupport (= 7.0.4) + activemodel (7.1.3.4) + activesupport (= 7.1.3.4) + activerecord (7.1.3.4) + activemodel (= 7.1.3.4) + activesupport (= 7.1.3.4) + timeout (>= 0.4.0) + activerecord-yugabytedb-adapter (7.1.3.4) + activerecord (= 7.1.3.4) + yugabytedb-ysql (~> 0.3) + activestorage (7.1.3.4) + actionpack (= 7.1.3.4) + activejob (= 7.1.3.4) + activerecord (= 7.1.3.4) + activesupport (= 7.1.3.4) marcel (~> 1.0) - mini_mime (>= 1.1.0) - activesupport (7.0.4) + activesupport (7.1.3.4) + base64 + bigdecimal concurrent-ruby (~> 1.0, >= 1.0.2) + connection_pool (>= 2.2.5) + drb i18n (>= 1.6, < 2) minitest (>= 5.1) + mutex_m tzinfo (~> 2.0) + base64 (0.2.0) + bigdecimal (3.1.8) bootsnap (1.18.3) msgpack (~> 1.2) builder (3.3.0) byebug (11.1.3) concurrent-ruby (1.3.1) + connection_pool (2.4.1) crass (1.0.6) date (3.3.4) + drb (2.2.1) erubi (1.12.0) ffi (1.17.0-x86_64-linux-gnu) globalid (1.2.1) activesupport (>= 6.1) i18n (1.14.5) concurrent-ruby (~> 1.0) + io-console (0.7.2) + irb (1.14.0) + rdoc (>= 4.0.0) + reline (>= 0.4.2) listen (3.7.1) rb-fsevent (~> 0.10, >= 0.10.3) rb-inotify (~> 0.9, >= 0.9.10) @@ -94,11 +111,11 @@ GEM net-pop net-smtp marcel (1.0.4) - method_source (1.1.0) mini_mime (1.1.5) minitest (5.23.1) msgpack (1.7.2) - net-imap (0.4.13) + mutex_m (0.2.0) + net-imap (0.4.14) date net-protocol net-pop (0.1.2) @@ -110,26 +127,34 @@ GEM nio4r (2.7.3) nokogiri (1.16.5-x86_64-linux) racc (~> 1.4) + pg (1.4.6) + psych (5.1.2) + stringio puma (5.6.8) nio4r (~> 2.0) racc (1.8.0) rack (2.2.9) + rack-session (1.0.2) + rack (< 3) rack-test (2.1.0) rack (>= 1.3) - rails (7.0.4) - actioncable (= 7.0.4) - actionmailbox (= 7.0.4) - actionmailer (= 7.0.4) - actionpack (= 7.0.4) - actiontext (= 7.0.4) - actionview (= 7.0.4) - activejob (= 7.0.4) - activemodel (= 7.0.4) - activerecord (= 7.0.4) - activestorage (= 7.0.4) - activesupport (= 7.0.4) + rackup (1.0.0) + rack (< 3) + webrick + rails (7.1.3.4) + actioncable (= 7.1.3.4) + actionmailbox (= 7.1.3.4) + actionmailer (= 7.1.3.4) + actionpack (= 7.1.3.4) + actiontext (= 7.1.3.4) + actionview (= 7.1.3.4) + activejob (= 7.1.3.4) + activemodel (= 7.1.3.4) + activerecord (= 7.1.3.4) + activestorage (= 7.1.3.4) + activesupport (= 7.1.3.4) bundler (>= 1.15.0) - railties (= 7.0.4) + railties (= 7.1.3.4) rails-dom-testing (2.2.0) activesupport (>= 5.0.0) minitest @@ -137,17 +162,22 @@ GEM rails-html-sanitizer (1.6.0) loofah (~> 2.21) nokogiri (~> 1.14) - railties (7.0.4) - actionpack (= 7.0.4) - activesupport (= 7.0.4) - method_source + railties (7.1.3.4) + actionpack (= 7.1.3.4) + activesupport (= 7.1.3.4) + irb + rackup (>= 1.0.0) rake (>= 12.2) - thor (~> 1.0) - zeitwerk (~> 2.5) + thor (~> 1.0, >= 1.2.2) + zeitwerk (~> 2.6) rake (13.2.1) rb-fsevent (0.11.2) rb-inotify (0.11.1) ffi (~> 1.0) + rdoc (6.7.0) + psych (>= 4.0.0) + reline (0.5.9) + io-console (~> 0.5) spring (4.2.1) spring-watcher-listen (2.1.0) listen (>= 2.7, < 4.0) @@ -159,31 +189,34 @@ GEM actionpack (>= 4.0) activesupport (>= 4.0) sprockets (>= 3.0.0) + stringio (3.1.1) thor (1.3.1) timeout (0.4.1) tzinfo (2.0.6) concurrent-ruby (~> 1.0) + webrick (1.8.1) websocket-driver (0.7.6) websocket-extensions (>= 0.1.0) websocket-extensions (0.1.5) - yugabyte_ysql (0.3) - zeitwerk (2.6.16) + yugabytedb-ysql (0.4) + zeitwerk (2.6.17) PLATFORMS x86_64-linux DEPENDENCIES - activerecord-yugabytedb-adapter (= 7.0.4.1) + activerecord-yugabytedb-adapter (~> 7.1.3.4) bootsnap (>= 1.1.0) byebug listen (~> 3.7.1) + pg (~> 1.4.4) puma (~> 5.6.5) - rails (= 7.0.4) + rails (= 7.1.3.4) spring spring-watcher-listen (~> 2.1.0) sprockets-rails (~> 3.0.0) tzinfo-data - yugabyte_ysql (~> 0.3) + yugabytedb-ysql (~> 0.4) BUNDLED WITH 2.3.27