diff --git a/internal/cmd/commands/database/init.go b/internal/cmd/commands/database/init.go index 6a55d148cb..c278de830a 100644 --- a/internal/cmd/commands/database/init.go +++ b/internal/cmd/commands/database/init.go @@ -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 { diff --git a/internal/cmd/commands/database/migrate.go b/internal/cmd/commands/database/migrate.go index a9ba0cc959..914b603854 100644 --- a/internal/cmd/commands/database/migrate.go +++ b/internal/cmd/commands/database/migrate.go @@ -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 { diff --git a/internal/db/schema/manager_test.go b/internal/db/schema/manager_test.go index 08f8124cad..a728347e42 100644 --- a/internal/db/schema/manager_test.go +++ b/internal/db/schema/manager_test.go @@ -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 { diff --git a/internal/db/schema/migrations/generate/generate.go b/internal/db/schema/migrations/generate/generate.go index 8d4aad41e5..42300a5d80 100644 --- a/internal/db/schema/migrations/generate/generate.go +++ b/internal/db/schema/migrations/generate/generate.go @@ -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}} diff --git a/internal/db/schema/postgres_migration.gen.go b/internal/db/schema/postgres_migration.gen.go index 94d31c6f44..8db7f370ae 100644 --- a/internal/db/schema/postgres_migration.gen.go +++ b/internal/db/schema/postgres_migration.gen.go @@ -4,7 +4,6 @@ package schema func init() { migrationStates["postgres"] = migrationState{ - devMigration: false, binarySchemaVersion: 1003, upMigrations: map[int][]byte{ 1: []byte(` diff --git a/internal/db/schema/state.go b/internal/db/schema/state.go index acbd0c8159..f2af40a24b 100644 --- a/internal/db/schema/state.go +++ b/internal/db/schema/state.go @@ -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 { diff --git a/internal/db/schema/state_test.go b/internal/db/schema/state_test.go index 2031e66513..fa24919f50 100644 --- a/internal/db/schema/state_test.go +++ b/internal/db/schema/state_test.go @@ -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")) -}