summaryrefslogtreecommitdiff
path: root/bin/cleanup
diff options
context:
space:
mode:
Diffstat (limited to 'bin/cleanup')
-rwxr-xr-xbin/cleanup20
1 files changed, 20 insertions, 0 deletions
diff --git a/bin/cleanup b/bin/cleanup
index 6ccbb07d..b77fdb4e 100755
--- a/bin/cleanup
+++ b/bin/cleanup
@@ -55,6 +55,26 @@ async function cleanup() {
}
})
+ await models.Author.findAll({
+ include: [{
+ model: models.Note,
+ as: 'note',
+ attributes: ['id']
+ }],
+ attributes: ['id', 'noteId']
+ }).then(async function(authors) {
+ for(let i =0, authorCount = authors.length; i< authorCount; i++) {
+ const item = authors[i]
+ if(item.noteId != null && !item.note) {
+ await models.Author.destroy({
+ where: {
+ id: item.id
+ }})
+ logger.info(`Deleted authorship ${item.id} from note ${item.noteId}`)
+ }
+ }
+ })
+
await models.Revision.findAll({
include: [{
model: models.Note,