Module: AfterMigrate
- Defined in:
- lib/after_migrate.rb,
lib/after_migrate/store.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, Stores
Classes: Configuration, Railtie
Constant Summary
collapse
- VERSION =
'0.2.2'
Class Method Summary
collapse
Class Method Details
.affected_tables ⇒ Object
Persistent cross-migration store: schema_name => Concurrent::Set<table_name>
40
41
42
|
# File 'lib/after_migrate.rb', line 40
def affected_tables
store.affected_tables
end
|
.configuration ⇒ Object
27
28
29
|
# File 'lib/after_migrate.rb', line 27
def configuration
@configuration ||= Configuration.new
end
|
31
32
33
|
# File 'lib/after_migrate.rb', line 31
def configure
yield(configuration)
end
|
.log(msg) ⇒ Object
35
36
37
|
# File 'lib/after_migrate.rb', line 35
def log(msg)
warn "[after_migrate] #{msg}" if AfterMigrate.configuration.verbose
end
|
.merge_tables(schema, table_names) ⇒ Object
44
45
46
|
# File 'lib/after_migrate.rb', line 44
def merge_tables(schema, table_names)
store.merge_tables(schema, table_names)
end
|
.reset! ⇒ Object
56
57
58
|
# File 'lib/after_migrate.rb', line 56
def reset!
store.reset!
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.
50
51
52
53
54
|
# File 'lib/after_migrate.rb', line 50
def run!(schema: nil)
return unless configuration.enabled
Executor.call(schema:)
end
|
.store ⇒ Object
60
61
62
63
64
65
|
# File 'lib/after_migrate.rb', line 60
def store
key = [configuration.store.to_s, configuration.store_path.to_s, configuration.run_id.to_s]
@store = nil if @store_key != key
@store_key = key
@store ||= build_store
end
|