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/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/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/indexes_collector.rb,
lib/online_migrations/schema_statements.rb,
lib/online_migrations/application_record.rb,
lib/online_migrations/background_migration.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/background_migrations/config.rb,
lib/online_migrations/background_migrations/migration.rb,
lib/online_migrations/background_migrations/scheduler.rb,
lib/online_migrations/background_migrations/copy_column.rb,
lib/online_migrations/background_migrations/migration_job.rb,
lib/online_migrations/background_schema_migrations/config.rb,
lib/online_migrations/background_migrations/reset_counters.rb,
lib/online_migrations/background_migrations/backfill_column.rb,
lib/online_migrations/background_migrations/migration_runner.rb,
lib/online_migrations/background_schema_migrations/migration.rb,
lib/online_migrations/background_schema_migrations/scheduler.rb,
lib/online_migrations/background_migrations/migration_helpers.rb,
lib/generators/online_migrations/background_migration_generator.rb,
lib/online_migrations/background_migrations/migration_job_runner.rb,
lib/online_migrations/background_migrations/delete_orphaned_records.rb,
lib/online_migrations/background_schema_migrations/migration_runner.rb,
lib/online_migrations/background_schema_migrations/migration_helpers.rb,
lib/online_migrations/background_migrations/delete_associated_records.rb,
lib/online_migrations/background_migrations/migration_status_validator.rb,
lib/online_migrations/background_migrations/perform_action_on_relation.rb,
lib/online_migrations/background_migrations/migration_job_status_validator.rb,
lib/online_migrations/background_schema_migrations/migration_status_validator.rb,
lib/online_migrations/background_migrations/background_migration_class_validator.rb

Defined Under Namespace

Modules: BackgroundMigrations, BackgroundSchemaMigrations, ChangeColumnTypeHelpers, CommandRecorder, DatabaseTasks, ErrorMessages, Migration, Migrator, SchemaCache, SchemaCache71, SchemaCache72, SchemaDumper, SchemaStatements, Utils, VerboseSqlLogs Classes: ApplicationRecord, BackgroundMigration, BackgroundMigrationGenerator, BatchIterator, CommandChecker, Config, ConstantLockRetrier, CopyTrigger, Error, ExponentialLockRetrier, ForeignKeysCollector, IndexDefinition, IndexesCollector, InstallGenerator, LockRetrier, NullLockRetrier, UnsafeMigration, UpgradeGenerator, WrappedConnection

Constant Summary collapse

VERSION =
"0.20.2"

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.current_migrationObject



76
77
78
# File 'lib/online_migrations.rb', line 76

def current_migration
  @current_migration
end

Class Method Details

.configObject



82
83
84
# File 'lib/online_migrations.rb', line 82

def config
  @config ||= Config.new
end

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

Yields:



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

def configure
  yield config
end

.deprecatorObject



97
98
99
100
101
102
103
104
# File 'lib/online_migrations.rb', line 97

def deprecator
  @deprecator ||=
    if Utils.ar_version >= 7.1
      ActiveSupport::Deprecation.new(nil, "online_migrations")
    else
      ActiveSupport::Deprecation
    end
end

.loadObject



107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
# File 'lib/online_migrations.rb', line 107

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)
  elsif OnlineMigrations::Utils.ar_version >= 7.1
    ActiveRecord::ConnectionAdapters::SchemaCache.prepend(OnlineMigrations::SchemaCache71)
  else
    ActiveRecord::ConnectionAdapters::SchemaCache.prepend(OnlineMigrations::SchemaCache)
  end
end

.run_background_migrationsObject Also known as: run_background_data_migrations

Run background data migrations



87
88
89
# File 'lib/online_migrations.rb', line 87

def run_background_migrations
  BackgroundMigrations::Scheduler.run
end

.run_background_schema_migrationsObject

Run background schema migrations



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

def run_background_schema_migrations
  BackgroundSchemaMigrations::Scheduler.run
end