Module: UsesguidMigrations::ActiveRecordExtensions::ConnectionAdapters::TableDefinition::InstanceMethods
- Defined in:
- lib/usesguid_migrations/active_record_extensions/connection_adapters/table_definition.rb
Instance Method Summary collapse
- #guid(name, options = {}) ⇒ Object
- #guid_primary_key(name) ⇒ Object
- #references_with_guid(name, options = {}) ⇒ Object
Instance Method Details
#guid(name, options = {}) ⇒ Object
24 25 26 27 28 29 30 31 |
# File 'lib/usesguid_migrations/active_record_extensions/connection_adapters/table_definition.rb', line 24 def guid( name, ={} ) @associative_keys = [] if @associative_keys.nil? .merge!( :limit => 22 ) # make not nullable the default for a guid column as it is likely a foreign key .merge!( :null => false ) unless [:null] == true @associative_keys << OpenStruct.new( :name => name, :options => ) column( name, :binary, ) end |
#guid_primary_key(name) ⇒ Object
13 14 15 16 |
# File 'lib/usesguid_migrations/active_record_extensions/connection_adapters/table_definition.rb', line 13 def guid_primary_key( name ) @primary_key_name = name column( name, :binary, :limit => 22, :null => false ) end |
#references_with_guid(name, options = {}) ⇒ Object
18 19 20 21 22 |
# File 'lib/usesguid_migrations/active_record_extensions/connection_adapters/table_definition.rb', line 18 def references_with_guid( name, ={} ) name = name.to_s name = "#{name}_id" unless name.end_with?( "_id" ) guid( name, ) end |