Files
threshold/internal/db/schema/testing.go
T
429247f407 [COMPLIANCE] Update Copyright Headers (#6282)
* [COMPLIANCE] Update Copyright and License Headers

* chore: make gen to generate files with copyright headers

* chore: update missed copyright headers

---------

Co-authored-by: hashicorp-copywrite[bot] <110428419+hashicorp-copywrite[bot]@users.noreply.github.com>
Co-authored-by: Justin Nguyen <justin.nguyen@hashicorp.com>
2026-01-28 11:05:07 -06:00

48 lines
1.2 KiB
Go

// Copyright IBM Corp. 2020, 2025
// SPDX-License-Identifier: BUSL-1.1
package schema
import (
"github.com/hashicorp/boundary/internal/db/schema/internal/edition"
"github.com/hashicorp/boundary/internal/db/schema/migration"
)
// PartialEditions is used by TestCreatePartialEditions. It is a map of edition
// names to the max version that should be included.
type PartialEditions map[string]int
// TestCreatePartialEditions is used by tests to create a subset of the Edition migrations.
func TestCreatePartialEditions(dialect Dialect, p PartialEditions) edition.Editions {
editions.Lock()
defer editions.Unlock()
e := make(edition.Editions, 0, len(p))
for _, ee := range editions.m[dialect] {
maxVer, ok := p[ee.Name]
if ok {
edition := edition.Edition{
Name: ee.Name,
Dialect: ee.Dialect,
Priority: ee.Priority,
LatestVersion: nilVersion,
Migrations: make(migration.Migrations),
}
for k, b := range ee.Migrations {
if k > maxVer {
continue
}
edition.Migrations[k] = b
if k > edition.LatestVersion {
edition.LatestVersion = k
}
}
e = append(e, edition)
}
}
return e
}