func (s *StateStore) deleteJobVersions(index uint64, job *structs.Job, txn *memdb.Txn) error {
	iter, err := txn.Get("job_version", "id_prefix", job.ID)
	if err != nil {
		return err
	}

	for {
		raw := iter.Next()
		if raw == nil {
			break
		}

		// Ensure the ID is an exact match
		j := raw.(*structs.Job)
		if j.ID != job.ID {
			continue
		}

		if _, err = txn.DeleteAll("job_version", "id", job.ID, job.Version); err != nil {
			return fmt.Errorf("deleting job versions failed: %v", err)
		}
	}

	if err := txn.Insert("index", &IndexEntry{"job_summary", index}); err != nil {
		return fmt.Errorf("index update failed: %v", err)
	}

	return nil
}
// deleteJobVersions deletes all versions of the given job.
deleteJobVersions deletes all versions of the given job.
// deleteJobVersions deletes all versions of the given job .
func (s *StateStore) deleteJobVersions(index uint64, job *structs.Job, txn *memdb.Txn) error {
	iter, err := txn.Get("job_version", "id_prefix", job.ID)
	if err != nil {
		return err
	}
	for {
		raw := iter.Next()
		if raw == nil {
			break
		}
		j := raw.(*structs.Job)
		if j.ID != job.ID {
			continue
		}
		if _, err = txn.DeleteAll("job_version", "id", job.ID, job.Version); err != nil {
			return fmt.Errorf("deleting job versions failed: %v", err)
		}
	}
	if err := txn.Insert("index", &IndexEntry{"job_summary", index}); err != nil {
		return fmt.Errorf("index update failed: %v", err)
	}
	return nil
}
func ( s * StateStore ) deleteJobVersions ( index uint64 , job * structs . Job , txn * memdb . Txn ) error { iter , err := txn . Get ( " " , " " , job . ID ) if err != nil { return err } for { raw := iter . Next ( ) if raw == nil { break } j := raw . ( * structs . Job ) if j . ID != job . ID { continue } if _ , err = txn . DeleteAll ( " " , " " , job . ID , job . Version ) ; err != nil { return fmt . Errorf ( " " , err ) } } if err := txn . Insert ( " " , & IndexEntry { " " , index } ) ; err != nil { return fmt . Errorf ( " " , err ) } return nil }
deleteJobVersions deletes all versions of the given job.
deleteJobVersions deletes all versions of the given job .
// Ensure the ID is an exact match