Removing dev migration feature and checks (#892)

pull/895/head
Todd Knight 5 years ago committed by GitHub
parent 955ae41215
commit 57d4bf2bfd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -5,7 +5,6 @@ import (
"github.com/hashicorp/boundary/internal/cmd/base"
"github.com/hashicorp/boundary/internal/cmd/config"
"github.com/hashicorp/boundary/internal/db/schema"
"github.com/hashicorp/boundary/internal/errors"
"github.com/hashicorp/boundary/internal/types/scope"
"github.com/hashicorp/boundary/sdk/wrapper"
@ -37,7 +36,6 @@ type InitCommand struct {
flagLogLevel string
flagLogFormat string
flagMigrationUrl string
flagAllowDevMigrations bool
flagSkipInitialLoginRoleCreation bool
flagSkipAuthMethodCreation bool
flagSkipScopesCreation bool
@ -117,12 +115,6 @@ func (c *InitCommand) Flags() *base.FlagSets {
f = set.NewFlagSet("Init Options")
f.BoolVar(&base.BoolVar{
Name: "allow-development-migrations",
Target: &c.flagAllowDevMigrations,
Usage: "If set the init will continue even if the schema includes database update steps that may not be supported in the next official release. Boundary does not provide a rollback mechanism so a backup should be taken independently if needed.",
})
f.BoolVar(&base.BoolVar{
Name: "skip-initial-login-role-creation",
Target: &c.flagSkipInitialLoginRoleCreation,
@ -185,19 +177,6 @@ func (c *InitCommand) Run(args []string) (retCode int) {
dialect := "postgres"
if schema.DevMigration(dialect) != c.flagAllowDevMigrations {
if schema.DevMigration(dialect) {
c.UI.Error(base.WrapAtLength("This version of the binary has " +
"dev database schema updates which may not be supported in the " +
"next official release. To proceed anyways please use the " +
"'-allow-development-migrations' flag."))
return 2
} else {
c.UI.Warn(base.WrapAtLength("The '-allow-development-migrations' " +
"flag was set but this binary has no dev database schema updates."))
}
}
c.srv = base.NewServer(&base.Command{UI: c.UI})
if err := c.srv.SetupLogging(c.flagLogLevel, c.flagLogFormat, c.Config.LogLevel, c.Config.LogFormat); err != nil {

@ -5,7 +5,6 @@ import (
"github.com/hashicorp/boundary/internal/cmd/base"
"github.com/hashicorp/boundary/internal/cmd/config"
"github.com/hashicorp/boundary/internal/db/schema"
"github.com/hashicorp/boundary/sdk/wrapper"
wrapping "github.com/hashicorp/go-kms-wrapping"
"github.com/hashicorp/vault/sdk/helper/mlock"
@ -97,12 +96,6 @@ func (c *MigrateCommand) Flags() *base.FlagSets {
f = set.NewFlagSet("Migration options")
f.BoolVar(&base.BoolVar{
Name: "allow-development-migrations",
Target: &c.flagAllowDevMigrations,
Usage: "If set the migrate command will continue even if the schema includes database update steps that may not be supported in the next official release. Boundary does not provide a rollback mechanism so a backup should be taken independently if needed.",
})
f.StringVar(&base.StringVar{
Name: "migration-url",
Target: &c.flagMigrationUrl,
@ -135,19 +128,6 @@ func (c *MigrateCommand) Run(args []string) (retCode int) {
dialect := "postgres"
if schema.DevMigration(dialect) != c.flagAllowDevMigrations {
if schema.DevMigration(dialect) {
c.UI.Error(base.WrapAtLength("This version of the binary has " +
"dev database schema updates which may not be supported in the " +
"next official release. To proceed anyways please use the " +
"'-allow-development-migrations' flag."))
return 2
} else {
c.UI.Warn(base.WrapAtLength("The '-allow-development-migrations' " +
"flag was set but this binary has no dev database schema updates."))
}
}
c.srv = base.NewServer(&base.Command{UI: c.UI})
if err := c.srv.SetupLogging(c.flagLogLevel, c.flagLogFormat, c.Config.LogLevel, c.Config.LogFormat); err != nil {

@ -239,7 +239,6 @@ func TestManager_SharedLock(t *testing.T) {
// Creates a new migrationState only with the versions <= the provided maxVer
func createPartialMigrationState(om migrationState, maxVer int) migrationState {
nState := migrationState{
devMigration: om.devMigration,
upMigrations: make(map[int][]byte),
}
for k := range om.upMigrations {

@ -35,23 +35,14 @@ func generate(dialect string) {
}
var upContents []ContentValues
isDev := false
var lRelVer, largestSchemaVersion int
var largestSchemaVersion int
for _, ver := range versions {
var verVal int
switch ver {
case "dev":
verVal = lRelVer + 1
default:
v, err := strconv.Atoi(ver)
if err != nil {
fmt.Printf("error reading major schema version directory %q. Must be a number or 'dev'\n", ver)
os.Exit(1)
}
verVal = v
if verVal > lRelVer {
lRelVer = verVal
}
verVal, err := strconv.Atoi(ver)
if err != nil {
fmt.Printf("error reading major schema version directory %q. Must be a number: %v\n", ver, err)
os.Exit(1)
}
dir, err := os.Open(fmt.Sprintf("%s/%s/%s", srcDir, dialect, ver))
@ -65,10 +56,6 @@ func generate(dialect string) {
os.Exit(1)
}
if ver == "dev" && len(names) > 0 {
isDev = true
}
sort.Strings(names)
for _, name := range names {
if !strings.HasSuffix(name, ".sql") {
@ -121,12 +108,10 @@ func generate(dialect string) {
if err := migrationsTemplate.Execute(outBuf, struct {
Type string
UpValues []ContentValues
DevMigration bool
BinarySchemaVersion int
}{
Type: dialect,
UpValues: upContents,
DevMigration: isDev,
BinarySchemaVersion: largestSchemaVersion,
}); err != nil {
fmt.Printf("error executing migrations value template for dialect %s: %s", dialect, err)
@ -148,7 +133,6 @@ var migrationsTemplate = template.Must(template.Must(template.New("Content").Par
func init() {
migrationStates["{{ .Type }}"] = migrationState{
devMigration: {{ .DevMigration }},
binarySchemaVersion: {{ .BinarySchemaVersion }},
upMigrations: map[int][]byte{
{{range .UpValues }}{{ template "Content" . }}{{end}}

@ -4,7 +4,6 @@ package schema
func init() {
migrationStates["postgres"] = migrationState{
devMigration: false,
binarySchemaVersion: 1003,
upMigrations: map[int][]byte{
1: []byte(`

@ -5,11 +5,6 @@ const nilVersion = -1
// migrationState is meant to be populated by the generated migration code and
// contains the internal representation of a schema in the current binary.
type migrationState struct {
// devMigration is true if the database schema that would be applied by
// MigrateStore would be from files in the /dev directory which indicates it would
// not be safe to run in a non dev environment.
devMigration bool
// binarySchemaVersion provides the database schema version supported by
// this binary.
binarySchemaVersion int
@ -28,12 +23,6 @@ func getUpMigration(dialect string) map[int][]byte {
return ms.upMigrations
}
// DevMigration returns true iff the provided dialect has changes which are still in development.
func DevMigration(dialect string) bool {
ms, ok := migrationStates[dialect]
return ok && ms.devMigration
}
// BinarySchemaVersion provides the schema version that this binary supports for the provided dialect.
// If the binary doesn't support this dialect -1 is returned.
func BinarySchemaVersion(dialect string) int {

@ -12,12 +12,3 @@ func TestBinarySchemaVersion(t *testing.T) {
assert.Equal(t, 3, BinarySchemaVersion(dialect))
assert.Equal(t, nilVersion, BinarySchemaVersion("unknown_dialect"))
}
func TestDevMigration(t *testing.T) {
dialect := "test_devmigrations"
migrationStates[dialect] = migrationState{devMigration: true}
assert.True(t, DevMigration(dialect))
migrationStates[dialect] = migrationState{devMigration: false}
assert.False(t, DevMigration(dialect))
assert.False(t, DevMigration("unknown_dialect"))
}

Loading…
Cancel
Save