Module: SchemaPlus::ForeignKeys::ActiveRecord::Migration::CommandRecorder
- Defined in:
- lib/schema_plus/foreign_keys/active_record/migration/command_recorder.rb
Instance Attribute Summary collapse
Instance Method Summary collapse
-
#add_reference(table_name, ref_name, options = {}) ⇒ Object
seems like this is fixing a rails bug: change_table foo, bulk: true { |t| t.references :bar } results in an ‘unknown method :add_reference_sql’ (with mysql2).
Instance Attribute Details
#schema_plus_foreign_keys_config ⇒ Object
:nodoc:
8 9 10 |
# File 'lib/schema_plus/foreign_keys/active_record/migration/command_recorder.rb', line 8 def schema_plus_foreign_keys_config @schema_plus_foreign_keys_config end |
Instance Method Details
#add_reference(table_name, ref_name, options = {}) ⇒ Object
seems like this is fixing a rails bug:
change_table foo, bulk: true { |t| t.references :bar }
results in an ‘unknown method :add_reference_sql’ (with mysql2)
should track it down separately and submit a patch/fix to rails
16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/schema_plus/foreign_keys/active_record/migration/command_recorder.rb', line 16 def add_reference(table_name, ref_name, = {}) #:nodoc: polymorphic = .delete(:polymorphic) [:references] = nil if polymorphic # ugh. copying and pasting code from ::ActiveRecord::ConnectionAdapters::SchemaStatements#add_reference = .delete(:index) add_column(table_name, "#{ref_name}_id", :integer, **) add_column(table_name, "#{ref_name}_type", :string, polymorphic.is_a?(Hash) ? polymorphic : ) if polymorphic add_index(table_name, polymorphic ? %w[id type].map{ |t| "#{ref_name}_#{t}" } : "#{ref_name}_id", .is_a?(Hash) ? : {}) if self end |