module Cell::Ext::Migration
Public Class Methods
intercept(methods)
click to toggle source
We intercept these methods, and only execute if appropriate according to execute_ddl?
Calls superclass method
# File lib/cell/ext/migration.rb, line 93 def self.intercept(methods) methods.each do |method| define_method(method) do |*args, &block| super(*args, &block) if execute_ddl? end end end
Public Instance Methods
exec_migration(con, direction)
click to toggle source
Calls superclass method
# File lib/cell/ext/migration.rb, line 140 def exec_migration(con, direction) if ! targeted? with_context(:global, global_schema) do super end with_context(:prototype, prototype_schema) do super end else with_context(:target, tenant_schema, exclusive: true) do super end end end
global_schema()
click to toggle source
# File lib/cell/ext/migration.rb, line 115 def global_schema Meta.global_schema end
initialize_cell!()
click to toggle source
This is our super-special initialization function.
# File lib/cell/ext/migration.rb, line 136 def initialize_cell! execute "CREATE SCHEMA #{connection.quote_schema_name(prototype_schema)}" end
prototype_schema()
click to toggle source
# File lib/cell/ext/migration.rb, line 119 def prototype_schema Meta.prototype_schema end
target()
click to toggle source
# File lib/cell/ext/migration.rb, line 127 def target Model.current end
targeted?()
click to toggle source
# File lib/cell/ext/migration.rb, line 131 def targeted? !! target end
tenant_schema()
click to toggle source
# File lib/cell/ext/migration.rb, line 123 def tenant_schema target.schema_name end