Module: AfterMigrate
- Defined in:
- lib/after_migrate.rb,
lib/after_migrate/railtie.rb,
lib/after_migrate/version.rb,
lib/after_migrate/executor.rb,
lib/after_migrate/collector.rb,
lib/after_migrate/adapters/sql.rb,
lib/after_migrate/adapters/mysql.rb,
lib/after_migrate/adapters/sqlite.rb,
lib/after_migrate/adapters/postgresql.rb
Defined Under Namespace
Modules: Collector, Executor, Mysql, Postgresql, Sql, Sqlite
Classes: Configuration, Railtie
Constant Summary
collapse
- VERSION =
'0.2.0'
Class Method Summary
collapse
Class Method Details
.affected_tables ⇒ Object
Persistent cross-migration store: schema_name => Concurrent::Set<table_name>
36
37
38
|
# File 'lib/after_migrate.rb', line 36
def affected_tables
@affected_tables ||= Concurrent::Map.new
end
|
.configuration ⇒ Object
23
24
25
|
# File 'lib/after_migrate.rb', line 23
def configuration
@configuration ||= Configuration.new
end
|
27
28
29
|
# File 'lib/after_migrate.rb', line 27
def configure
yield(configuration)
end
|
.log(msg) ⇒ Object
31
32
33
|
# File 'lib/after_migrate.rb', line 31
def log(msg)
warn "[after_migrate] #{msg}" if AfterMigrate.configuration.verbose
end
|
.merge_tables(schema, table_names) ⇒ Object
40
41
42
43
44
45
|
# File 'lib/after_migrate.rb', line 40
def merge_tables(schema, table_names)
return if table_names.blank?
set = affected_tables.compute_if_absent(schema) { Concurrent::Set.new }
set.merge(table_names)
end
|
.reset! ⇒ Object
55
56
57
|
# File 'lib/after_migrate.rb', line 55
def reset!
@affected_tables = nil
end
|
.run!(schema: nil) ⇒ Object
Trigger database maintenance on all collected tables, then clear the store. In multi-tenant setups call this once after all tenant migrations complete.
49
50
51
52
53
|
# File 'lib/after_migrate.rb', line 49
def run!(schema: nil)
return unless configuration.enabled
Executor.call(schema:)
end
|