Skip to content

Commit

Permalink
prepare code for multidb (#55)
Browse files Browse the repository at this point in the history
* prepare code for multidb

* small refactor

* fix
  • Loading branch information
ka8725 authored May 1, 2024
1 parent 8a671e0 commit 8cf43a4
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
23 changes: 22 additions & 1 deletion lib/actual_db_schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,28 @@ class << self
}

def self.migrated_folder
Rails.root.join("tmp", "migrated").tap { |folder| FileUtils.mkdir_p(folder) }
migrated_folders.first
end

def self.migrated_folders
return [default_migrated_folder] unless migrations_paths

Array(migrations_paths).map do |path|
if path.end_with?("db/migrate")
default_migrated_folder
else
postfix = path.split("/").last
Rails.root.join("tmp", "migrated_#{postfix}")
end
end
end

def self.default_migrated_folder
Rails.root.join("tmp", "migrated")
end

def self.migrations_paths
ActiveRecord::Base.connection_db_config.migrations_paths
end

def self.migration_filename(fullpath)
Expand Down
1 change: 1 addition & 0 deletions lib/actual_db_schema/store.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ class Store

def write(filename)
basename = File.basename(filename)
FileUtils.mkdir_p(folder)
FileUtils.copy(filename, folder.join(basename))
record_metadata(filename)
end
Expand Down

0 comments on commit 8cf43a4

Please sign in to comment.