mirror of
https://github.com/zoriya/flood.git
synced 2025-12-06 07:16:18 +00:00
29 lines
610 B
TypeScript
29 lines
610 B
TypeScript
import Users from '../../models/Users';
|
|
|
|
const migrationError = (err?: Error) => {
|
|
if (err) {
|
|
console.error(err);
|
|
}
|
|
console.error('Migration failed. You need to reset the databases manually.');
|
|
process.exit();
|
|
};
|
|
|
|
const migration = () => {
|
|
return Users.listUsers().then((users) => {
|
|
return Promise.all(
|
|
users.map(async (user) => {
|
|
if (user.timestamp != null) {
|
|
// No need to migrate.
|
|
return;
|
|
}
|
|
|
|
await Users.updateUser(user.username, {});
|
|
}),
|
|
).catch((err) => {
|
|
migrationError(err);
|
|
});
|
|
});
|
|
};
|
|
|
|
export default migration;
|