Skip to content

Commit

Permalink
prepare code for multidb
Browse files Browse the repository at this point in the history
  • Loading branch information
ka8725 committed May 1, 2024
1 parent 8a671e0 commit 848b048
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
19 changes: 18 additions & 1 deletion lib/actual_db_schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,24 @@ 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 [Rails.root.join("tmp", "migrated")] unless migrations_paths

Array(migrations_paths).map do |path|
if path.end_with?("db/migrate")
Rails.root.join("tmp", "migrated")
else
postfix = path.split("/").last
Rails.root.join("tmp", "migrated_#{postfix}")
end
end
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 848b048

Please sign in to comment.