From: Chocobozzz Date: Wed, 15 Nov 2017 10:25:53 +0000 (+0100) Subject: Fix error when creating a fresh database X-Git-Tag: v0.0.1-alpha~217 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=59c857da5961e2bcddcfd07832783c1e4afcd01a;p=oweals%2Fpeertube.git Fix error when creating a fresh database --- 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' }) }