]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/initializers/installer.js
Server: add unique to unique indexes
[github/Chocobozzz/PeerTube.git] / server / initializers / installer.js
index 4823bc8c82b13aa7a62f950b51246826d8118c6f..fb63b81ac64c1e962446bc4adf283c60f4d6836e 100644 (file)
@@ -96,6 +96,7 @@ function createOAuthAdminIfNotExist (callback) {
 
     const username = 'root'
     const role = constants.USER_ROLES.ADMIN
+    const createOptions = {}
     let password = ''
 
     // Do not generate a random password for tests
@@ -105,25 +106,27 @@ function createOAuthAdminIfNotExist (callback) {
       if (process.env.NODE_APP_INSTANCE) {
         password += process.env.NODE_APP_INSTANCE
       }
+
+      // Our password is weak so do not validate it
+      createOptions.validate = false
     } else {
       password = passwordGenerator(8, true)
     }
 
-    const user = db.User.build({
+    const userData = {
       username,
       password,
       role
-    })
+    }
 
-    user.save().asCallback(function (err, createdUser) {
+    db.User.create(userData, createOptions).asCallback(function (err, createdUser) {
       if (err) return callback(err)
 
       logger.info('Username: ' + username)
       logger.info('User password: ' + password)
 
-      logger.info('Creating Application collection.')
-      const application = db.Application.build({ sqlSchemaVersion: constants.LAST_SQL_SCHEMA_VERSION })
-      application.save().asCallback(callback)
+      logger.info('Creating Application table.')
+      db.Application.create({ migrationVersion: constants.LAST_MIGRATION_VERSION }).asCallback(callback)
     })
   })
 }