[CORL-649] Migrations (#2597)

* feat: added migration framework

* chore: added premod user status migration

* feat: enhanced error handling of migrations

* fix: added missing argument from abstract method

* fix: another templating blunder

* fix: removed debug code

* feat: enhanced migration tracking

* fix: remove skipping migrations

* feat: moved indexing to migration system

* fix: linting
This commit is contained in:
Wyatt Johnson
2019-10-01 16:00:27 +00:00
committed by GitHub
parent b3b26bd9f3
commit c045f52daa
40 changed files with 1038 additions and 469 deletions
@@ -107,20 +107,17 @@ const UserDrawerAccountHistory: FunctionComponent<Props> = ({ user }) => {
});
});
// FIXME: (wyattjoh) once migration has been performed, remove check
if (user.status.premod) {
// Merge in all the premod history items.
user.status.premod.history.forEach(record => {
history.push({
kind: "premod",
action: {
action: record.active ? "created" : "removed",
},
date: new Date(record.createdAt),
takenBy: record.createdBy ? record.createdBy.username : system,
});
// Merge in all the premod history items.
user.status.premod.history.forEach(record => {
history.push({
kind: "premod",
action: {
action: record.active ? "created" : "removed",
},
date: new Date(record.createdAt),
takenBy: record.createdBy ? record.createdBy.username : system,
});
}
});
user.status.username.history.forEach((record, i) => {
history.push({
@@ -66,8 +66,7 @@ const UserStatusChangeContainer: FunctionComponent<Props> = props => {
}, [user, removeUserSuspension]);
const handlePremod = useCallback(() => {
// FIXME: (wyattjoh) once migration has been performed, remove check
if (user.status.premod && user.status.premod.active) {
if (user.status.premod.active) {
return;
}
setShowPremod(true);
@@ -83,8 +82,7 @@ const UserStatusChangeContainer: FunctionComponent<Props> = props => {
}, [setShowPremod]);
const handleRemovePremod = useCallback(() => {
// FIXME: (wyattjoh) once migration has been performed, remove check
if (!user.status.premod || !user.status.premod.active) {
if (!user.status.premod.active) {
return;
}
removeUserPremod({ userID: user.id });
@@ -138,8 +136,7 @@ const UserStatusChangeContainer: FunctionComponent<Props> = props => {
onRemovePremod={handleRemovePremod}
banned={user.status.ban.active}
suspended={user.status.suspension.active}
// FIXME: (wyattjoh) once migration has been performed, remove check
premod={Boolean(user.status.premod && user.status.premod.active)}
premod={user.status.premod.active}
fullWidth={fullWidth}
>
<UserStatusContainer user={user} />