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
19 20 21 22 23 |
# File 'lib/schema_plus/core/active_record/connection_adapters/table_definition.rb', line 19 def belongs_to(name, = {}) SchemaMonkey::Middleware::Migration::Column.start(caller: self, operation: :define, table_name: self.name, column_name: "#{name}_id", type: :reference, options: .deep_dup) do |env| super env.column_name.sub(/_id$/, ''), env. end end |
#column(name, type, options = {}) ⇒ Object
7 8 9 10 11 |
# File 'lib/schema_plus/core/active_record/connection_adapters/table_definition.rb', line 7 def column(name, type, = {}) SchemaMonkey::Middleware::Migration::Column.start(caller: self, operation: :define, table_name: self.name, column_name: name, type: type, options: .deep_dup) do |env| super env.column_name, env.type, env. end end |
#index(*args) ⇒ Object
25 26 27 28 29 30 31 |
# File 'lib/schema_plus/core/active_record/connection_adapters/table_definition.rb', line 25 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
13 14 15 16 17 |
# File 'lib/schema_plus/core/active_record/connection_adapters/table_definition.rb', line 13 def references(name, = {}) SchemaMonkey::Middleware::Migration::Column.start(caller: self, operation: :define, table_name: self.name, column_name: "#{name}_id", type: :reference, options: .deep_dup) do |env| super env.column_name.sub(/_id$/, ''), env. end end |