Class: ColdStorage::Railtie
- Inherits:
-
Rails::Railtie
- Object
- Rails::Railtie
- ColdStorage::Railtie
- Defined in:
- lib/cold_storage/railtie.rb
Overview
Rails wiring: the archivable macro, the logger, the rake tasks, and the
automatic schema sync after migrations.
Class Method Summary collapse
-
.hook_into_migrations! ⇒ Object
After the primary database changes, bring the archive schema along - for the archivable models only.
Class Method Details
.hook_into_migrations! ⇒ Object
After the primary database changes, bring the archive schema along - for the archivable models only.
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/cold_storage/railtie.rb', line 35 def self.hook_into_migrations! %w[db:migrate db:migrate:up db:migrate:down db:rollback db:schema:load].each do |name| next unless Rake::Task.task_defined?(name) Rake::Task[name].enhance do next unless ColdStorage.config.sync_schema_after_migrate sync = Rake::Task['cold_storage:schema:sync'] sync.reenable sync.invoke rescue ColdStorage::ConfigurationError => e Rails.logger&.info { "#{ColdStorage::Logging::PREFIX} skipping schema sync: #{e.}" } end end end |