Module: Cell::Migration
- Defined in:
- lib/cell/migration.rb
Defined Under Namespace
Modules: CommandRecorderFilter, ContextTracker, MetadataIntercept
Class Method Summary
collapse
Instance Method Summary
collapse
Class Method Details
.intercept(methods) ⇒ Object
We intercept every method given, and only execute it if appropriate according to execute_ddl?
93
94
95
96
97
98
99
|
# File 'lib/cell/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
|
Instance Method Details
#exec_migration(con, direction) ⇒ Object
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
|
# File 'lib/cell/migration.rb', line 142
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
|
#initialize_cell! ⇒ Object
This is our super-special initialization function.
137
138
139
140
|
# File 'lib/cell/migration.rb', line 137
def initialize_cell!
CloneSchema.install_function!
execute "CREATE SCHEMA #{connection.quote_schema_name(prototype_schema)}"
end
|
#prototype_schema ⇒ Object
#target ⇒ Object
128
129
130
|
# File 'lib/cell/migration.rb', line 128
def target
Cell::Model.current
end
|
#targeted? ⇒ Boolean
132
133
134
|
# File 'lib/cell/migration.rb', line 132
def targeted?
!! target
end
|
#tenant_schema ⇒ Object
124
125
126
|
# File 'lib/cell/migration.rb', line 124
def tenant_schema
target.schema_name
end
|