diff --git a/ansible/roles/schulcloud-server-init/templates/configmap_file_init.yml.j2 b/ansible/roles/schulcloud-server-init/templates/configmap_file_init.yml.j2 index 0618bf1926..e8ae316161 100644 --- a/ansible/roles/schulcloud-server-init/templates/configmap_file_init.yml.j2 +++ b/ansible/roles/schulcloud-server-init/templates/configmap_file_init.yml.j2 @@ -611,5 +611,3 @@ data: fi # ========== End of TSP system creation - # Database indexes synchronization, it's crucial until we have all the entities in NestJS app. - npm run syncIndexes diff --git a/package.json b/package.json index 06a9cc0204..4dec643c59 100644 --- a/package.json +++ b/package.json @@ -108,7 +108,6 @@ "nest:test:cov": "jest \"^((?!\\.load\\.spec\\.ts).)*\\.spec\\.ts$\" --coverage --force-exit --maxWorkers='50%'", "nest:test:debug": "jest --runInBand", "nest:lint": "eslint apps --ignore-path .gitignore", - "syncIndexes": "node ./scripts/syncIndexes.js", "ensureIndexes": "npm run nest:start:console -- database sync-indexes", "schoolExport": "node ./scripts/schoolExport.js", "schoolImport": "node ./scripts/schoolImport.js", diff --git a/scripts/syncIndexes.js b/scripts/syncIndexes.js deleted file mode 100644 index 1ff5b89ff5..0000000000 --- a/scripts/syncIndexes.js +++ /dev/null @@ -1,48 +0,0 @@ -/* eslint-disable no-underscore-dangle */ -/* eslint-disable no-console */ -const mongoose = require('mongoose'); -const util = require('util'); -const appPromise = require('../src/app'); - -const logger = require('../src/logger'); - -const getModels = () => Object.entries(mongoose.models); - -const extractIndexFromModel = ([modelName, model]) => [modelName, (model.schema || {})._indexes]; - -const formatToLog = (data) => util.inspect(data, { depth: 5, compact: true, breakLength: 120 }); - -const syncIndexes = async () => { - try { - logger.alert('load app...'); - await appPromise(); - logger.alert('start syncIndexes..'); - const models = getModels(); - for (const [modelName, model] of models) { - logger.alert(`${modelName}.syncIndexes()`); - try { - // eslint-disable-next-line no-await-in-loop - await model.syncIndexes(); - } catch (err) { - logger.alert(err); - } - } - - logger.alert('..syncIndex finished!'); - - try { - const indexes = models.map(extractIndexFromModel); - logger.alert(formatToLog(indexes)); - } catch (err) { - logger.alert(err); - } - - logger.alert('..script finished!'); - process.exit(0); - } catch (error) { - logger.error(error); - process.exit(1); - } -}; - -syncIndexes();