]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/initializers/database.ts
Remove references to author
[github/Chocobozzz/PeerTube.git] / server / initializers / database.ts
index b410b0c18067879d4828b403434703551e3474b0..aefb6da3a020708128fcd0ce9ae8c876e5ca1b07 100644 (file)
@@ -15,8 +15,9 @@ import { BlacklistedVideoModel } from './../models/video/video-blacklist-interfa
 import { VideoFileModel } from './../models/video/video-file-interface'
 import { VideoAbuseModel } from './../models/video/video-abuse-interface'
 import { VideoChannelModel } from './../models/video/video-channel-interface'
-import { UserModel } from './../models/user/user-interface'
-import { UserVideoRateModel } from './../models/user/user-video-rate-interface'
+import { UserModel } from '../models/account/user-interface'
+import { AccountVideoRateModel } from '../models/account/account-video-rate-interface'
+import { AccountFollowModel } from '../models/account/account-follow-interface'
 import { TagModel } from './../models/video/tag-interface'
 import { RequestModel } from './../models/request/request-interface'
 import { RequestVideoQaduModel } from './../models/request/request-video-qadu-interface'
@@ -26,7 +27,7 @@ import { PodModel } from './../models/pod/pod-interface'
 import { OAuthTokenModel } from './../models/oauth/oauth-token-interface'
 import { OAuthClientModel } from './../models/oauth/oauth-client-interface'
 import { JobModel } from './../models/job/job-interface'
-import { AuthorModel } from './../models/video/author-interface'
+import { AccountModel } from './../models/account/account-interface'
 import { ApplicationModel } from './../models/application/application-interface'
 
 const dbname = CONFIG.DATABASE.DBNAME
@@ -38,17 +39,14 @@ const database: {
   init?: (silent: boolean) => Promise<void>,
 
   Application?: ApplicationModel,
-  Author?: AuthorModel,
+  Account?: AccountModel,
   Job?: JobModel,
   OAuthClient?: OAuthClientModel,
   OAuthToken?: OAuthTokenModel,
   Pod?: PodModel,
-  RequestToPod?: RequestToPodModel,
-  RequestVideoEvent?: RequestVideoEventModel,
-  RequestVideoQadu?: RequestVideoQaduModel,
-  Request?: RequestModel,
   Tag?: TagModel,
-  UserVideoRate?: UserVideoRateModel,
+  AccountVideoRate?: AccountVideoRateModel,
+  AccountFollow?: AccountFollowModel,
   User?: UserModel,
   VideoAbuse?: VideoAbuseModel,
   VideoChannel?: VideoChannelModel,
@@ -64,6 +62,7 @@ const sequelize = new Sequelize(dbname, username, password, {
   port: CONFIG.DATABASE.PORT,
   benchmark: isTestInstance(),
   isolationLevel: Sequelize.Transaction.ISOLATION_LEVELS.SERIALIZABLE,
+  operatorsAliases: false,
 
   logging: (message: string, benchmark: number) => {
     let newMessage = message
@@ -83,9 +82,14 @@ database.init = async (silent: boolean) => {
   const filePaths = await getModelFiles(modelDirectory)
 
   for (const filePath of filePaths) {
-    const model = sequelize.import(filePath)
+    try {
+      const model = sequelize.import(filePath)
 
-    database[model['name']] = model
+      database[model['name']] = model
+    } catch (err) {
+      logger.error('Cannot import database model %s.', filePath, err)
+      process.exit(0)
+    }
   }
 
   for (const modelName of Object.keys(database)) {
@@ -120,7 +124,7 @@ async function getModelFiles (modelDirectory: string) {
     return true
   })
 
-  const tasks: Bluebird<any>[] = []
+  const tasks: Promise<any>[] = []
 
   // For each directory we read it and append model in the modelFilePaths array
   for (const directory of directories) {