_append_to_attribute_definitions

in lib/aws-record/record/table_migration.rb [169:190]


      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 do |a|
              a[:attribute_name] == key_schema[:attribute_name]
            end
            next if 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
        create_opts[:attribute_definitions] = attr_def
      end