_gsi_updates

in lib/aws-record/record/table_config.rb [429:472]


      def _gsi_updates(resp)
        gsi_updates = []
        attributes_referenced = Set.new
        remote_gsis = resp.table.global_secondary_indexes
        local_gsis = _global_secondary_indexes
        remote_idx, local_idx = _gsi_index_names(remote_gsis, local_gsis)
        create_candidates = local_idx - remote_idx
        update_candidates = local_idx.intersection(remote_idx)
        create_candidates.each do |index_name|
          gsi = @model_class.global_secondary_indexes_for_migration.find do |i|
            i[:index_name].to_s == index_name
          end
          gsi[:key_schema].each do |k|
            attributes_referenced.add(k[:attribute_name])
          end
          if @billing_mode == "PROVISIONED"
            lgsi = @global_secondary_indexes[index_name.to_sym]
            gsi[:provisioned_throughput] = lgsi.provisioned_throughput
          end
          gsi_updates << {
            create: gsi
          }
        end
        
        if @billing_mode == "PROVISIONED"
          update_candidates.each do |index_name|
            lgsi = @global_secondary_indexes[index_name.to_sym]
            gsi_updates << {
              update: {
                index_name: index_name,
                provisioned_throughput: lgsi.provisioned_throughput
              }
            }
          end
        end
        attribute_definitions = _attribute_definitions
        incremental_attributes = attributes_referenced.map do |attr_name|
          attribute_definitions.find do |ad|
            ad[:attribute_name] == attr_name
          end
        end
        [gsi_updates, incremental_attributes]
      end