lxd/db/schema/schema.go
func checkAllUpdatesAreApplied(tx *sql.Tx, updates []Update) error {
	versions, err := selectSchemaVersions(tx)
	if err != nil {
		return fmt.Errorf("failed to fetch update versions: %v", err)
	}

	if len(versions) == 0 {
		return fmt.Errorf("expected schema table to contain at least one row")
	}

	err = checkSchemaVersionsHaveNoHoles(versions)
	if err != nil {
		return err
	}

	current := versions[len(versions)-1]
	if current != len(updates) {
		return fmt.Errorf("update level is %d, expected %d", current, len(updates))
	}
	return nil
}
func checkAllUpdatesAreApplied(tx *sql.Tx, updates []Update) error {
	versions, err := selectSchemaVersions(tx)
	if err != nil {
		return fmt.Errorf("failed to fetch update versions: %v", err)
	}

	if len(versions) == 0 {
		return fmt.Errorf("expected schema table to contain at least one row")
	}

	err = checkSchemaVersionsHaveNoHoles(versions)
	if err != nil {
		return err
	}

	current := versions[len(versions)-1]
	if current != len(updates) {
		return fmt.Errorf("update level is %d, expected %d", current, len(updates))
	}
	return nil
}
func checkAllUpdatesAreApplied ( tx * sql . Tx , updates [ ] Update ) error { versions , err := selectSchemaVersions ( tx ) if err != nil { return fmt . Errorf ( " " , err ) } if len ( versions ) == 0 { return fmt . Errorf ( " " ) } err = checkSchemaVersionsHaveNoHoles ( versions ) if err != nil { return err } current := versions [ len ( versions ) - 1 ] if current != len ( updates ) { return fmt . Errorf ( " " , current , len ( updates ) ) } return nil }
// Check that all the given updates are applied.
Check that all the given updates are applied .