From db7fa3d0ed0758fdca29efd337c85200a290becf Mon Sep 17 00:00:00 2001 From: Alex Sharov Date: Wed, 12 Jan 2022 20:30:23 +0700 Subject: [PATCH] Change major db version check (#3241) * remove major jump check * remove major jump check --- migrations/migrations.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/migrations/migrations.go b/migrations/migrations.go index b9f38c42c..d11adb3f6 100644 --- a/migrations/migrations.go +++ b/migrations/migrations.go @@ -14,6 +14,8 @@ import ( "github.com/ugorji/go/codec" ) +const MIN_MAJOR_VERSION = 3 // DB migrations before this number are removed - no way to migrate + // migrations apply sequentially in order of this array, skips applied migrations // it allows - don't worry about merge conflicts and use switch branches // see also dbutils.Migrations - it stores context in which each transaction was exectured - useful for bug-reports @@ -146,9 +148,8 @@ func (m *Migrator) Apply(db kv.RwDB, datadir string) error { return fmt.Errorf("cannot downgrade minor DB version from %d.%d to %d.%d", major, minor, kv.DBSchemaVersion.Major, kv.DBSchemaVersion.Major) } } else { - // major < kv.DBSchemaVersion.Major - if kv.DBSchemaVersion.Major-major > 1 { - return fmt.Errorf("cannot upgrade major DB version for more than 1 version from %d to %d, use integration tool if you know what you are doing", major, kv.DBSchemaVersion.Major) + if major < MIN_MAJOR_VERSION { + return fmt.Errorf("cannot upgrade major DB version from %d, minimum allowed version of db to apply DB migrations is %d, use integration tool if you know what you are doing", major, MIN_MAJOR_VERSION) } } }