// IncrementAndGetSerial returns the next-available serial number, incrementing
// it in the database before returning. There must be an active transaction to
// call this method. Callers should Begin the transaction, call this method,
// perform any other work, and Commit at the end once the certificate is issued.
func (cadb *CertificateAuthorityDatabaseImpl) IncrementAndGetSerial(tx *gorp.Transaction) (int64, error) {
	r, err := tx.Exec("REPLACE INTO serialNumber (stub) VALUES ('a');")
	if err != nil {
		return -1, err
	}

	return r.LastInsertId()
}