Module: StrongMigrations

Defined in:
lib/strong_migrations.rb,
lib/strong_migrations/checker.rb,
lib/strong_migrations/railtie.rb,
lib/strong_migrations/version.rb,
lib/strong_migrations/migration.rb,
lib/strong_migrations/database_tasks.rb,
lib/strong_migrations/alphabetize_columns.rb,
lib/generators/strong_migrations/install_generator.rb

Defined Under Namespace

Modules: AlphabetizeColumns, DatabaseTasks, Generators, Migration Classes: Checker, Error, Railtie, UnsafeMigration

Constant Summary collapse

VERSION =
"0.7.2"

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.auto_analyzeObject

Returns the value of attribute auto_analyze.



18
19
20
# File 'lib/strong_migrations.rb', line 18

def auto_analyze
  @auto_analyze
end

.check_downObject

Returns the value of attribute check_down.



18
19
20
# File 'lib/strong_migrations.rb', line 18

def check_down
  @check_down
end

.checksObject

Returns the value of attribute checks.



18
19
20
# File 'lib/strong_migrations.rb', line 18

def checks
  @checks
end

.enabled_checksObject

Returns the value of attribute enabled_checks.



18
19
20
# File 'lib/strong_migrations.rb', line 18

def enabled_checks
  @enabled_checks
end

.error_messagesObject

Returns the value of attribute error_messages.



18
19
20
# File 'lib/strong_migrations.rb', line 18

def error_messages
  @error_messages
end

.lock_timeoutObject

Returns the value of attribute lock_timeout.



18
19
20
# File 'lib/strong_migrations.rb', line 18

def lock_timeout
  @lock_timeout
end

.lock_timeout_limitObject



226
227
228
229
230
231
# File 'lib/strong_migrations.rb', line 226

def self.lock_timeout_limit
  unless defined?(@lock_timeout_limit)
    @lock_timeout_limit = developer_env? ? false : 10
  end
  @lock_timeout_limit
end

.start_afterObject

Returns the value of attribute start_after.



18
19
20
# File 'lib/strong_migrations.rb', line 18

def start_after
  @start_after
end

.statement_timeoutObject

Returns the value of attribute statement_timeout.



18
19
20
# File 'lib/strong_migrations.rb', line 18

def statement_timeout
  @statement_timeout
end

.target_mariadb_versionObject

Returns the value of attribute target_mariadb_version.



18
19
20
# File 'lib/strong_migrations.rb', line 18

def target_mariadb_version
  @target_mariadb_version
end

.target_mysql_versionObject

Returns the value of attribute target_mysql_version.



18
19
20
# File 'lib/strong_migrations.rb', line 18

def target_mysql_version
  @target_mysql_version
end

.target_postgresql_versionObject

Returns the value of attribute target_postgresql_version.



18
19
20
# File 'lib/strong_migrations.rb', line 18

def target_postgresql_version
  @target_postgresql_version
end

.target_versionObject

Returns the value of attribute target_version.



18
19
20
# File 'lib/strong_migrations.rb', line 18

def target_version
  @target_version
end

Class Method Details

.add_check(&block) ⇒ Object



233
234
235
# File 'lib/strong_migrations.rb', line 233

def self.add_check(&block)
  checks << block
end

.check_enabled?(check, version: nil) ⇒ Boolean

Returns:

  • (Boolean)


245
246
247
248
249
250
251
252
# File 'lib/strong_migrations.rb', line 245

def self.check_enabled?(check, version: nil)
  if enabled_checks[check]
    start_after = enabled_checks[check][:start_after] || StrongMigrations.start_after
    !version || version > start_after
  else
    false
  end
end

.developer_env?Boolean

private

Returns:

  • (Boolean)


222
223
224
# File 'lib/strong_migrations.rb', line 222

def self.developer_env?
  defined?(Rails) && (Rails.env.development? || Rails.env.test?)
end

.disable_check(check) ⇒ Object



241
242
243
# File 'lib/strong_migrations.rb', line 241

def self.disable_check(check)
  enabled_checks.delete(check)
end

.enable_check(check, start_after: nil) ⇒ Object



237
238
239
# File 'lib/strong_migrations.rb', line 237

def self.enable_check(check, start_after: nil)
  enabled_checks[check] = {start_after: start_after}
end