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

Feat/support multi db #52

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
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
4 changes: 4 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand All @@ -217,6 +220,7 @@ GEM
zeitwerk (2.6.12)

PLATFORMS
arm64-darwin-21
x86_64-darwin-20
x86_64-darwin-22
x86_64-linux
Expand Down
6 changes: 3 additions & 3 deletions lib/actual_db_schema/commands/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion test/dummy_app/db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
14 changes: 14 additions & 0 deletions test/dummy_app/db/secondary_schema.rb
Original file line number Diff line number Diff line change
@@ -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
18 changes: 14 additions & 4 deletions test/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down