|
|
@@ -1,7 +1,6 @@
|
|
|
// eslint-disable-next-line import/no-named-as-default
|
|
|
import Config from '~/server/models/config';
|
|
|
-import User from '~/server/models/user';
|
|
|
-import { getMongoUri, mongoOptions } from '~/server/util/mongoose-utils';
|
|
|
+import { getModelSafely, getMongoUri, mongoOptions } from '~/server/util/mongoose-utils';
|
|
|
import loggerFactory from '~/utils/logger';
|
|
|
|
|
|
|
|
|
@@ -14,6 +13,8 @@ module.exports = {
|
|
|
logger.info('Apply migration');
|
|
|
mongoose.connect(getMongoUri(), mongoOptions);
|
|
|
|
|
|
+ const User = getModelSafely('User') || require('~/server/models/user')();
|
|
|
+
|
|
|
const appInstalled = await Config.findOne({ key: 'app:installed' });
|
|
|
if (appInstalled != null && appInstalled.createdAt == null) {
|
|
|
const initialUser = await User.find().limit(1).sort({ createdAt: 1 });
|