MM-25507: Remove old migration state marker before running fresh migration (#14768)

While resetting permissions, we were not removing old migration state residue
for the EMOJIS_PERMISSIONS_MIGRATION_KEY and GUEST_ROLES_CREATION_MIGRATION_KEY.
Therefore, during their migration, they got skipped because the code checks
if a migration key is already present or not.

To fix this, we remove the migration key just as we do for ADVANCED_PERMISSIONS_MIGRATION_KEY.

Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
Этот коммит содержится в:
Agniva De Sarker
2020-06-25 13:36:47 +05:30
коммит произвёл GitHub
родитель 23e306bc3a
Коммит 1648b11e82
3 изменённых файлов: 36 добавлений и 2 удалений

Просмотреть файл

@@ -58,6 +58,16 @@ func (a *App) ResetPermissionsSystem() *model.AppError {
return err
}
// Remove the "System" table entry that marks the emoji permissions migration as done.
if _, err := a.Srv().Store.System().PermanentDeleteByName(EMOJIS_PERMISSIONS_MIGRATION_KEY); err != nil {
return err
}
// Remove the "System" table entry that marks the guest roles permissions migration as done.
if _, err := a.Srv().Store.System().PermanentDeleteByName(GUEST_ROLES_CREATION_MIGRATION_KEY); err != nil {
return err
}
// Now that the permissions system has been reset, re-run the migration to reinitialise it.
a.DoAppMigrations()