func (db *DB) schemaIndexPrefix(name string) (id byte, err error) {
	if name == "" {
		return 0, errors.New("index name cannot be blank")
	}
	s, err := db.getSchema()
	if err != nil {
		return 0, fmt.Errorf("get schema: %w", err)
	}
	nextID := keyPrefixIndexStart
	for i, f := range s.Indexes {
		if i >= nextID {
			nextID = i + 1
		}
		if f.Name == name {
			return i, nil
		}
	}
	id = nextID
	s.Indexes[id] = indexSpec{
		Name: name,
	}
	return id, db.putSchema(s)
}
schemaIndexID retrieves the complete LevelDB prefix for
a particular index.
package shed
import (
	"encoding/json"
	"errors"
	"fmt"
)
var (
	keySchema = []byte{0}
	keyPrefixFields byte = 1
	keyPrefixIndexStart byte = 2  
)
type schema struct {
	Fields  map[string]fieldSpec `json:"fields"`   
	Indexes map[byte]indexSpec   `json:"indexes"`  
}
type fieldSpec struct {
	Type string `json:"type"`
}
type indexSpec struct {
	Name string `json:"name"`
}
func (db *DB) schemaFieldKey(name, fieldType string) (key []byte, err error) {
	if name == "" {
		return nil, errors.New("field name cannot be blank")
	}
	if fieldType == "" {
		return nil, errors.New("field type cannot be blank")
	}
	s, err := db.getSchema()
	if err != nil {
		return nil, fmt.Errorf("get schema: %w", err)
	}
	var found bool
	for n, f := range s.Fields {
		if n == name {
			if f.Type != fieldType {
				return nil, fmt.Errorf("field %q of type %q stored as %q in db", name, fieldType, f.Type)
			}
			break
		}
	}
	if !found {
		s.Fields[name] = fieldSpec{
			Type: fieldType,
		}
		err := db.putSchema(s)
		if err != nil {
			return nil, fmt.Errorf("put schema: %w", err)
		}
	}
	return append([]byte{keyPrefixFields}, []byte(name)...), nil
}
func (db *DB) RenameIndex(name, newName string) (renamed bool, err error) {
	if name == "" {
		return false, errors.New("index name cannot be blank")
	}
	if newName == "" {
		return false, errors.New("new index name cannot be blank")
	}
	if newName == name {
		return false, nil
	}
	s, err := db.getSchema()
	if err != nil {
		return false, fmt.Errorf("get schema: %w", err)
	}
	for i, f := range s.Indexes {
		if f.Name == name {
			s.Indexes[i] = indexSpec{
				Name: newName,
			}
			return true, db.putSchema(s)
		}
		if f.Name == newName {
			return true, nil
		}
	}
	return false, nil
}