Module: AR::UUID::Schema
- Defined in:
- lib/ar/uuid/schema.rb
Instance Method Summary collapse
- #add_reference(table_name, ref_name, **options) ⇒ Object
- #create_table(table_name, **options, &block) ⇒ Object
Instance Method Details
#add_reference(table_name, ref_name, **options) ⇒ Object
25 26 27 28 29 |
# File 'lib/ar/uuid/schema.rb', line 25 def add_reference(table_name, ref_name, **) [:type] ||= "text" super end |
#create_table(table_name, **options, &block) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/ar/uuid/schema.rb', line 6 def create_table(table_name, **, &block) override_id = !.key?(:id) [:id] = false if override_id prefix = .delete(:prefix) || table_name default_function = proc do AR::UUID.default_function_with_prefix(prefix) end super(table_name, **) do |t| if override_id t.primary_key :id, :text, default: default_function end instance_exec(t, &block) end end |