Module: OnlineMigrations

Extended by:
ActiveSupport::Autoload
Defined in:
lib/online_migrations.rb,
lib/online_migrations/utils.rb,
lib/online_migrations/config.rb,
lib/online_migrations/version.rb,
lib/online_migrations/migrator.rb,
lib/online_migrations/migration.rb,
lib/online_migrations/shard_aware.rb,
lib/online_migrations/copy_trigger.rb,
lib/online_migrations/lock_retrier.rb,
lib/online_migrations/schema_cache.rb,
lib/online_migrations/schema_dumper.rb,
lib/online_migrations/batch_iterator.rb,
lib/online_migrations/data_migration.rb,
lib/online_migrations/database_tasks.rb,
lib/online_migrations/error_messages.rb,
lib/online_migrations/command_checker.rb,
lib/online_migrations/command_recorder.rb,
lib/online_migrations/index_definition.rb,
lib/online_migrations/verbose_sql_logs.rb,
lib/online_migrations/schema_statements.rb,
lib/online_migrations/application_record.rb,
lib/online_migrations/foreign_keys_collector.rb,
lib/online_migrations/change_column_type_helpers.rb,
lib/generators/online_migrations/install_generator.rb,
lib/generators/online_migrations/upgrade_generator.rb,
lib/online_migrations/active_record_batch_enumerator.rb,
lib/online_migrations/background_data_migrations/config.rb,
lib/online_migrations/background_data_migrations/ticker.rb,
lib/generators/online_migrations/data_migration_generator.rb,
lib/online_migrations/background_schema_migrations/config.rb,
lib/online_migrations/background_data_migrations/migration.rb,
lib/online_migrations/background_data_migrations/scheduler.rb,
lib/online_migrations/background_data_migrations/copy_column.rb,
lib/online_migrations/background_schema_migrations/migration.rb,
lib/online_migrations/background_schema_migrations/scheduler.rb,
lib/online_migrations/background_data_migrations/migration_job.rb,
lib/online_migrations/background_data_migrations/reset_counters.rb,
lib/online_migrations/background_data_migrations/backfill_column.rb,
lib/online_migrations/background_data_migrations/migration_helpers.rb,
lib/online_migrations/background_schema_migrations/migration_runner.rb,
lib/online_migrations/background_schema_migrations/migration_helpers.rb,
lib/online_migrations/background_data_migrations/delete_orphaned_records.rb,
lib/online_migrations/background_data_migrations/delete_associated_records.rb,
lib/online_migrations/background_data_migrations/migration_status_validator.rb,
lib/online_migrations/background_data_migrations/perform_action_on_relation.rb,
lib/online_migrations/background_schema_migrations/migration_status_validator.rb

Defined Under Namespace

Modules: ActiveRecordBatchEnumerator, BackgroundDataMigrations, BackgroundSchemaMigrations, ChangeColumnTypeHelpers, CommandRecorder, DatabaseTasks, ErrorMessages, Migration, Migrator, SchemaCache, SchemaCache72, SchemaDumper, SchemaStatements, ShardAware, Utils, VerboseSqlLogs Classes: ApplicationRecord, BatchIterator, CommandChecker, Config, ConstantLockRetrier, CopyTrigger, DataMigration, DataMigrationGenerator, Error, ExponentialLockRetrier, ForeignKeysCollector, IndexDefinition, InstallGenerator, LockRetrier, NullLockRetrier, UnsafeMigration, UpgradeGenerator, WrappedConnection

Constant Summary collapse

DataMigrations =

Make aliases for less typing.

BackgroundDataMigrations
SchemaMigrations =
BackgroundSchemaMigrations
VERSION =
"0.29.3"

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.current_migrationObject



78
79
80
# File 'lib/online_migrations.rb', line 78

def current_migration
  @current_migration
end

Class Method Details

.configObject



84
85
86
# File 'lib/online_migrations.rb', line 84

def config
  @config ||= Config.new
end

.configure {|config| ... } ⇒ Object

Yields:



80
81
82
# File 'lib/online_migrations.rb', line 80

def configure
  yield config
end

.deprecatorObject



107
108
109
# File 'lib/online_migrations.rb', line 107

def deprecator
  @deprecator ||= ActiveSupport::Deprecation.new(nil, "online_migrations")
end

.loadObject



112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
# File 'lib/online_migrations.rb', line 112

def load
  require "active_record/connection_adapters/postgresql_adapter"
  ActiveRecord::ConnectionAdapters::PostgreSQLAdapter.prepend(OnlineMigrations::SchemaStatements)

  ActiveRecord::Migration.prepend(OnlineMigrations::Migration)
  ActiveRecord::Migrator.prepend(OnlineMigrations::Migrator)
  ActiveRecord::SchemaDumper.prepend(OnlineMigrations::SchemaDumper)

  ActiveRecord::Tasks::DatabaseTasks.singleton_class.prepend(OnlineMigrations::DatabaseTasks)
  ActiveRecord::Migration::CommandRecorder.include(OnlineMigrations::CommandRecorder)

  if OnlineMigrations::Utils.ar_version >= 7.2
    ActiveRecord::ConnectionAdapters::SchemaCache.prepend(OnlineMigrations::SchemaCache72)
  else
    ActiveRecord::ConnectionAdapters::SchemaCache.prepend(OnlineMigrations::SchemaCache)
  end

  if !ActiveRecord::Batches::BatchEnumerator.method_defined?(:use_ranges)
    ActiveRecord::Batches::BatchEnumerator.include(OnlineMigrations::ActiveRecordBatchEnumerator)
  end
end

.run_background_data_migrations(**options) ⇒ Object Also known as: run_background_migrations

Run background data migrations

Parameters:

  • options (Hash)

    a customizable set of options

Options Hash (**options):

  • :shard (String, Symbol, nil)

    The name of the shard to run background data migrations on. By default runs on all shards.



93
94
95
# File 'lib/online_migrations.rb', line 93

def run_background_data_migrations(**options)
  BackgroundDataMigrations::Scheduler.run(**options)
end

.run_background_schema_migrations(**options) ⇒ Object

Run background schema migrations

Parameters:

  • options (Hash)

    a customizable set of options

Options Hash (**options):

  • :shard (String, Symbol, nil)

    The name of the shard to run background schema migrations on. By default runs on all shards.



103
104
105
# File 'lib/online_migrations.rb', line 103

def run_background_schema_migrations(**options)
  BackgroundSchemaMigrations::Scheduler.run(**options)
end