-import { USER_ROLES, CONFIG, LAST_MIGRATION_VERSION, CACHE } from './constants'
-import { clientsExist, usersExist } from './checker'
-import { logger, createCertsIfNotExist, mkdirpPromise, rimrafPromise } from '../helpers'
-
-function installApplication () {
- return db.sequelize.sync()
- .then(() => removeCacheDirectories())
- .then(() => createDirectoriesIfNotExist())
- .then(() => createCertsIfNotExist())
- .then(() => createOAuthClientIfNotExist())
- .then(() => createOAuthAdminIfNotExist())
+import { createPrivateAndPublicKeys } from '../helpers/peertube-crypto'
+
+async function installApplication () {
+ try {
+ await db.sequelize.sync()
+ await removeCacheDirectories()
+ await createDirectoriesIfNotExist()
+ await createApplicationIfNotExist()
+ await createOAuthClientIfNotExist()
+ await createOAuthAdminIfNotExist()
+ } catch (err) {
+ logger.error('Cannot install application.', err)
+ throw err
+ }