Created
November 9, 2021 06:45
-
-
Save bibendi/c9e529eb0e43fcc3975b3a49881593cf to your computer and use it in GitHub Desktop.
Disabling schema dumping for the statistics database on Rails 6.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
raise "Remove patches below in Rails 7" if Rails::VERSION::MAJOR == 7 | |
Rake::Task["db:schema:load:statistics"]&.clear | |
Rake::Task["db:_dump:statistics"]&.clear | |
Rake::Task["db:schema:dump:statistics"]&.clear | |
Rake::Task["db:test:load_schema:statistics"]&.clear | |
namespace :db do | |
namespace :schema do | |
desc "Creates a database schema file (either db/schema.rb or db/structure.sql, depending on `config.active_record.schema_format`)" | |
task dump: :load_config do | |
ActiveRecord::Base.configurations.configs_for(env_name: ActiveRecord::Tasks::DatabaseTasks.env).each do |db_config| | |
if db_config.configuration_hash.fetch(:schema_dump, true) | |
ActiveRecord::Base.establish_connection(db_config) | |
ActiveRecord::Tasks::DatabaseTasks.dump_schema(db_config) | |
end | |
end | |
Rake::Task["db:schema:dump"].reenable | |
end | |
end | |
# Useful task to create databases from scratch | |
desc "Reset the database without running seeds" | |
task recreate: ["db:drop", "db:create", "db:schema:load:primary", "db:migrate"] | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment