use migration helpers in spec

This commit is contained in:
Dylan Knutson
2025-07-14 17:13:58 +00:00
parent c870eef9bc
commit 81ec3d2902
2 changed files with 26 additions and 64 deletions

View File

@@ -76,18 +76,19 @@ module ActiveRecord
end
# Main DSL method for defining auxiliary tables
sig { params(table_name: T.any(String, Symbol)).returns(AuxTableConfig) }
def aux_table(table_name)
table_name = table_name.to_sym
sig { params(aux_name: T.any(String, Symbol)).returns(AuxTableConfig) }
def aux_table(aux_name)
base_table = self.table_name
aux_table_name = :"#{base_table}_#{aux_name}_aux"
if aux_table_configurations.key?(table_name)
if aux_table_configurations.key?(aux_table_name)
Kernel.raise ArgumentError,
"Auxiliary table '#{table_name}' is already defined"
"Auxiliary '#{aux_name}' (table '#{aux_table_name}') is already defined"
end
aux_table_configurations[table_name] = config =
generate_aux_model_class(table_name)
setup_schema_loading_hook(table_name)
aux_table_configurations[aux_table_name] = config =
generate_aux_model_class(aux_table_name)
setup_schema_loading_hook(aux_table_name)
setup_auto_join_queries(config)
config