aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorChocobozzz <florian.bigard@gmail.com>2017-11-15 11:25:53 +0100
committerChocobozzz <florian.bigard@gmail.com>2017-11-27 19:40:52 +0100
commit59c857da5961e2bcddcfd07832783c1e4afcd01a (patch)
tree899998038c38fdf6a6238945a0fbc79181d5cea0
parent608624252466acf9f1d9ee1c1170bd4fe4d18d18 (diff)
downloadPeerTube-59c857da5961e2bcddcfd07832783c1e4afcd01a.tar.gz
PeerTube-59c857da5961e2bcddcfd07832783c1e4afcd01a.tar.zst
PeerTube-59c857da5961e2bcddcfd07832783c1e4afcd01a.zip
Fix error when creating a fresh database
-rw-r--r--client/src/app/+admin/follows/following-add/following-add.component.ts1
-rw-r--r--server/initializers/database.ts7
-rw-r--r--server/models/account/account.ts2
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 {
94 this.followService.follow(notEmptyHosts).subscribe( 94 this.followService.follow(notEmptyHosts).subscribe(
95 status => { 95 status => {
96 this.notificationsService.success('Success', 'Follow request(s) sent!') 96 this.notificationsService.success('Success', 'Follow request(s) sent!')
97 this.router.navigate([ '/admin/follows/following-list' ])
97 }, 98 },
98 99
99 err => this.notificationsService.error('Error', err.message) 100 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) => {
89 89
90 for (const modelName of Object.keys(database)) { 90 for (const modelName of Object.keys(database)) {
91 if ('associate' in database[modelName]) { 91 if ('associate' in database[modelName]) {
92 database[modelName].associate(database) 92 try {
93 database[modelName].associate(database)
94 } catch (err) {
95 logger.error('Cannot associate model %s.', modelName, err)
96 process.exit(0)
97 }
93 } 98 }
94 } 99 }
95 100
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) {
255 name: 'accountId', 255 name: 'accountId',
256 allowNull: false 256 allowNull: false
257 }, 257 },
258 as: 'following',
259 onDelete: 'cascade' 258 onDelete: 'cascade'
260 }) 259 })
261 260
@@ -264,7 +263,6 @@ function associate (models) {
264 name: 'targetAccountId', 263 name: 'targetAccountId',
265 allowNull: false 264 allowNull: false
266 }, 265 },
267 as: 'followers',
268 onDelete: 'cascade' 266 onDelete: 'cascade'
269 }) 267 })
270} 268}