Merge branch 'persistent.14'

This commit is contained in:
Shivaram Lingamneni 2020-02-22 23:10:52 -05:00
commit fb8b73e29a
76 changed files with 9725 additions and 772 deletions

View file

@ -36,22 +36,6 @@ type SchemaChange struct {
// maps an initial version to a schema change capable of upgrading it
var schemaChanges map[string]SchemaChange
type incompatibleSchemaError struct {
currentVersion string
requiredVersion string
}
func IncompatibleSchemaError(currentVersion string) (result *incompatibleSchemaError) {
return &incompatibleSchemaError{
currentVersion: currentVersion,
requiredVersion: latestDbSchema,
}
}
func (err *incompatibleSchemaError) Error() string {
return fmt.Sprintf("Database requires update. Expected schema v%s, got v%s", err.requiredVersion, err.currentVersion)
}
// InitDB creates the database, implementing the `oragono initdb` command.
func InitDB(path string) {
_, err := os.Stat(path)
@ -129,7 +113,7 @@ func openDatabaseInternal(config *Config, allowAutoupgrade bool) (db *buntdb.DB,
// successful autoupgrade, let's try this again:
return openDatabaseInternal(config, false)
} else {
err = IncompatibleSchemaError(version)
err = &utils.IncompatibleSchemaError{CurrentVersion: version, RequiredVersion: latestDbSchema}
return
}
}
@ -179,7 +163,7 @@ func UpgradeDB(config *Config) (err error) {
break
}
// unable to upgrade to the desired version, roll back
return IncompatibleSchemaError(version)
return &utils.IncompatibleSchemaError{CurrentVersion: version, RequiredVersion: latestDbSchema}
}
log.Println("attempting to update schema from version " + version)
err := change.Changer(config, tx)
@ -509,14 +493,14 @@ func schemaChangeV6ToV7(config *Config, tx *buntdb.Tx) error {
type accountSettingsLegacyV7 struct {
AutoreplayLines *int
NickEnforcement NickEnforcementMethod
AllowBouncer BouncerAllowedSetting
AllowBouncer MulticlientAllowedSetting
AutoreplayJoins bool
}
type accountSettingsLegacyV8 struct {
AutoreplayLines *int
NickEnforcement NickEnforcementMethod
AllowBouncer BouncerAllowedSetting
AllowBouncer MulticlientAllowedSetting
ReplayJoins ReplayJoinsSetting
}