Class: OnlineMigrations::BackgroundMigration
- Inherits:
-
Object
- Object
- OnlineMigrations::BackgroundMigration
- Defined in:
- lib/online_migrations/background_migration.rb
Overview
Base class that is inherited by the host application’s background migration classes.
Direct Known Subclasses
OnlineMigrations::BackgroundMigrations::BackfillColumn, OnlineMigrations::BackgroundMigrations::CopyColumn, OnlineMigrations::BackgroundMigrations::DeleteAssociatedRecords, OnlineMigrations::BackgroundMigrations::DeleteOrphanedRecords, OnlineMigrations::BackgroundMigrations::PerformActionOnRelation, OnlineMigrations::BackgroundMigrations::ResetCounters
Defined Under Namespace
Classes: NotFoundError
Class Method Summary collapse
-
.named(name) ⇒ BackgroundMigration
Finds a Background Migration with the given name.
Instance Method Summary collapse
-
#count ⇒ Integer, ...
Returns the count of rows that will be iterated over (optional, to be able to show progress).
-
#process_batch(_relation) ⇒ void
Processes one batch.
-
#relation ⇒ ActiveRecord::Relation
The relation to be iterated over.
Class Method Details
.named(name) ⇒ BackgroundMigration
Finds a Background Migration with the given name.
17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/online_migrations/background_migration.rb', line 17 def named(name) namespace = OnlineMigrations.config.background_migrations.migrations_module.constantize internal_namespace = ::OnlineMigrations::BackgroundMigrations migration = "#{namespace}::#{name}".safe_constantize || "#{internal_namespace}::#{name}".safe_constantize raise NotFoundError.new("Background Migration #{name} not found", name) if migration.nil? if !(migration.is_a?(Class) && migration < self) raise NotFoundError.new("#{name} is not a Background Migration", name) end migration end |
Instance Method Details
#count ⇒ Integer, ...
Returns the count of rows that will be iterated over (optional, to be able to show progress).
60 61 62 |
# File 'lib/online_migrations/background_migration.rb', line 60 def count :no_count end |
#process_batch(_relation) ⇒ void
This method returns an undefined value.
Processes one batch.
52 53 54 |
# File 'lib/online_migrations/background_migration.rb', line 52 def process_batch(_relation) raise NotImplementedError, "#{self.class.name} must implement a 'process_batch' method" end |
#relation ⇒ ActiveRecord::Relation
The relation to be iterated over.
40 41 42 |
# File 'lib/online_migrations/background_migration.rb', line 40 def relation raise NotImplementedError, "#{self.class.name} must implement a 'relation' method" end |