Module: SchemaPlus::Core::ActiveRecord::ConnectionAdapters::TableDefinition
- Defined in:
- lib/schema_plus/core/active_record/connection_adapters/table_definition.rb
Instance Method Summary collapse
- #belongs_to(name, options = {}) ⇒ Object
- #column(name, type, options = {}) ⇒ Object
- #index(*args) ⇒ Object
- #references(name, options = {}) ⇒ Object
Instance Method Details
#belongs_to(name, options = {}) ⇒ Object
21 22 23 24 25 26 |
# File 'lib/schema_plus/core/active_record/connection_adapters/table_definition.rb', line 21 def belongs_to(name, = {}) = .deep_dup SchemaMonkey::Middleware::Migration::Column.start(caller: self, operation: :define, table_name: self.name, column_name: "#{name}_id", type: :reference, options: ) do |env| super env.column_name.sub(/_id$/, ''), env..merge(_implements_reference: true) end end |
#column(name, type, options = {}) ⇒ Object
7 8 9 10 11 12 |
# File 'lib/schema_plus/core/active_record/connection_adapters/table_definition.rb', line 7 def column(name, type, = {}) = .deep_dup SchemaMonkey::Middleware::Migration::Column.start(caller: self, operation: :define, table_name: self.name, column_name: name, type: type, implements_reference: .delete(:_implements_reference), options: ) do |env| super env.column_name, env.type, env. end end |
#index(*args) ⇒ Object
28 29 30 31 32 33 34 |
# File 'lib/schema_plus/core/active_record/connection_adapters/table_definition.rb', line 28 def index(*args) = args. column_name = args.first SchemaMonkey::Middleware::Migration::Index.start(caller: self, operation: :define, table_name: self.name, column_names: column_name, options: .deep_dup) do |env| super env.column_names, env. end end |
#references(name, options = {}) ⇒ Object
14 15 16 17 18 19 |
# File 'lib/schema_plus/core/active_record/connection_adapters/table_definition.rb', line 14 def references(name, = {}) = .deep_dup SchemaMonkey::Middleware::Migration::Column.start(caller: self, operation: :define, table_name: self.name, column_name: "#{name}_id", type: :reference, options: ) do |env| super env.column_name.sub(/_id$/, ''), env..merge(_implements_reference: true) end end |