From 59c857da5961e2bcddcfd07832783c1e4afcd01a Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Wed, 15 Nov 2017 11:25:53 +0100 Subject: [PATCH] Fix error when creating a fresh database --- .../follows/following-add/following-add.component.ts | 1 + server/initializers/database.ts | 7 ++++++- server/models/account/account.ts | 2 -- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/client/src/app/+admin/follows/following-add/following-add.component.ts b/client/src/app/+admin/follows/following-add/following-add.component.ts index 0ceb4c1db..814c6f1a1 100644 --- a/client/src/app/+admin/follows/following-add/following-add.component.ts +++ b/client/src/app/+admin/follows/following-add/following-add.component.ts @@ -94,6 +94,7 @@ export class FollowingAddComponent implements OnInit { this.followService.follow(notEmptyHosts).subscribe( status => { this.notificationsService.success('Success', 'Follow request(s) sent!') + this.router.navigate([ '/admin/follows/following-list' ]) }, err => this.notificationsService.error('Error', err.message) diff --git a/server/initializers/database.ts b/server/initializers/database.ts index 19b5a0466..0a716e4fb 100644 --- a/server/initializers/database.ts +++ b/server/initializers/database.ts @@ -89,7 +89,12 @@ database.init = async (silent: boolean) => { for (const modelName of Object.keys(database)) { if ('associate' in database[modelName]) { - database[modelName].associate(database) + try { + database[modelName].associate(database) + } catch (err) { + logger.error('Cannot associate model %s.', modelName, err) + process.exit(0) + } } } diff --git a/server/models/account/account.ts b/server/models/account/account.ts index ee00c5aef..464105261 100644 --- a/server/models/account/account.ts +++ b/server/models/account/account.ts @@ -255,7 +255,6 @@ function associate (models) { name: 'accountId', allowNull: false }, - as: 'following', onDelete: 'cascade' }) @@ -264,7 +263,6 @@ function associate (models) { name: 'targetAccountId', allowNull: false }, - as: 'followers', onDelete: 'cascade' }) } -- 2.41.0