From 7ec15fc61228e4b3c2a3b585ed77a61bf40c01c3 Mon Sep 17 00:00:00 2001 From: rwehresmann Date: Fri, 12 Jan 2024 11:36:38 -0300 Subject: [PATCH 1/2] wip --- lib/actual_db_schema/commands/base.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/actual_db_schema/commands/base.rb b/lib/actual_db_schema/commands/base.rb index 016d06e..8277c74 100644 --- a/lib/actual_db_schema/commands/base.rb +++ b/lib/actual_db_schema/commands/base.rb @@ -9,9 +9,9 @@ def call raise "ActualDbSchema is disabled. Set ActualDbSchema.config[:enabled] = true to enable it." end - if ActiveRecord::Migration.current_version >= 6 - ActiveRecord::Tasks::DatabaseTasks.raise_for_multi_db(command: "db:rollback_branches") - end + # if ActiveRecord::Migration.current_version >= 6 + # ActiveRecord::Tasks::DatabaseTasks.raise_for_multi_db(command: "db:rollback_branches") + # end call_impl end From b1f855358f057e100cc9e3c574f7b749ef27e8a3 Mon Sep 17 00:00:00 2001 From: rwehresmann Date: Sun, 28 Jan 2024 18:08:36 -0300 Subject: [PATCH 2/2] wip --- Gemfile.lock | 4 ++++ test/dummy_app/db/schema.rb | 2 +- test/dummy_app/db/secondary_schema.rb | 14 ++++++++++++++ test/test_helper.rb | 18 ++++++++++++++---- 4 files changed, 33 insertions(+), 5 deletions(-) create mode 100644 test/dummy_app/db/secondary_schema.rb diff --git a/Gemfile.lock b/Gemfile.lock index 994ab99..4b3ac95 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -131,6 +131,8 @@ GEM net-smtp (0.4.0) net-protocol nio4r (2.5.9) + nokogiri (1.15.4-arm64-darwin) + racc (~> 1.4) nokogiri (1.15.4-x86_64-darwin) racc (~> 1.4) nokogiri (1.15.4-x86_64-linux) @@ -202,6 +204,7 @@ GEM parser (>= 3.2.1.0) ruby-progressbar (1.13.0) ruby2_keywords (0.0.5) + sqlite3 (1.6.8-arm64-darwin) sqlite3 (1.6.8-x86_64-darwin) sqlite3 (1.6.8-x86_64-linux) stringio (3.0.8) @@ -217,6 +220,7 @@ GEM zeitwerk (2.6.12) PLATFORMS + arm64-darwin-21 x86_64-darwin-20 x86_64-darwin-22 x86_64-linux diff --git a/test/dummy_app/db/schema.rb b/test/dummy_app/db/schema.rb index d4a2a0c..f23614c 100644 --- a/test/dummy_app/db/schema.rb +++ b/test/dummy_app/db/schema.rb @@ -10,5 +10,5 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema[7.1].define(version: 0) do +ActiveRecord::Schema[7.1].define(version: 2013_09_06_111513) do end diff --git a/test/dummy_app/db/secondary_schema.rb b/test/dummy_app/db/secondary_schema.rb new file mode 100644 index 0000000..03e704f --- /dev/null +++ b/test/dummy_app/db/secondary_schema.rb @@ -0,0 +1,14 @@ +# This file is auto-generated from the current state of the database. Instead +# of editing this file, please use the migrations feature of Active Record to +# incrementally modify your database, and then regenerate this schema definition. +# +# This file is the source Rails uses to define your schema when running `bin/rails +# db:schema:load`. When creating a new database, `bin/rails db:schema:load` tends to +# be faster and is potentially less error prone than running all of your +# migrations from scratch. Old migrations may fail to apply correctly if those +# migrations use external dependencies or application code. +# +# It's strongly recommended that you check this file into your version control system. + +ActiveRecord::Schema[7.1].define(version: 2013_09_06_111512) do +end diff --git a/test/test_helper.rb b/test/test_helper.rb index 06f2a87..678648d 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -18,11 +18,21 @@ def initialize Rails.application = FakeApplication.new db_config = { - adapter: "sqlite3", - database: "tmp/test.sqlite3" + "primary" => { + "adapter" => "sqlite3", + "database" => "tmp/primary.sqlite3" + }, + "secondary" => { + "adapter" => "sqlite3", + "database" => "tmp/secondary.sqlite3" + } } -ActiveRecord::Tasks::DatabaseTasks.database_configuration = { test: db_config } -ActiveRecord::Base.establish_connection(**db_config) + +ActiveRecord::Tasks::DatabaseTasks.database_configuration = { "test" => db_config } + +db_config.each do |db_name, config| + ActiveRecord::Base.establish_connection(config) +end ActualDbSchema.config[:enabled] = true