zyket 1.0.34 → 1.0.38

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zyket",
3
- "version": "1.0.34",
3
+ "version": "1.0.38",
4
4
  "main": "index.js",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1"
@@ -30,6 +30,7 @@
30
30
  "sequelize": "^6.37.7",
31
31
  "socket.io": "^4.8.1",
32
32
  "swagger-jsdoc": "^6.2.8",
33
- "swagger-ui-express": "^5.0.1"
33
+ "swagger-ui-express": "^5.0.1",
34
+ "umzug": "^3.8.2"
34
35
  }
35
36
  }
@@ -3,6 +3,7 @@ const Service = require("../Service");
3
3
  const fg = require('fast-glob');
4
4
  const fs = require('fs');
5
5
  const path = require('path');
6
+ const { Umzug, SequelizeStorage } = require('umzug')
6
7
 
7
8
  module.exports = class Database extends Service {
8
9
  #container;
@@ -78,6 +79,20 @@ module.exports = class Database extends Service {
78
79
  }
79
80
  }
80
81
 
82
+ async runMigrations(migrationsPath = 'src/models/migrations') {
83
+ const umzug = new Umzug({
84
+ migrations: { glob: `${migrationsPath}/*.js` },
85
+ context: {
86
+ queryInterface: this.#container.get('database').sequelize.getQueryInterface(),
87
+ container: this.#container
88
+ },
89
+ storage: new SequelizeStorage({ sequelize: this.#container.get('database').sequelize }),
90
+ logger: console
91
+ })
92
+
93
+ return await umzug.up()
94
+ }
95
+
81
96
  #createModelsFolder() {
82
97
  const path = 'src/models';
83
98
  if (!fs.existsSync(path)) fs.mkdirSync(path);