_append_to_attribute_definitions

in lib/aws-record/record/table_migration.rb [194:215]


      def _append_to_attribute_definitions(secondary_indexes, create_opts)
        attributes = @model.attributes
        attr_def = create_opts[:attribute_definitions]
        secondary_indexes.each do |si|
          si[:key_schema].each do |key_schema|
            exists = attr_def.find { |a|
              a[:attribute_name] == key_schema[:attribute_name]
            }
            unless exists
              attr = attributes.attribute_for(
                attributes.db_to_attribute_name(key_schema[:attribute_name])
              )
              attr_def << {
                attribute_name: attr.database_name,
                attribute_type: attr.dynamodb_type
              }
            end
          end
        end
        create_opts[:attribute_definitions] = attr_def
      end