@projectinvicta/nails 3.0.4 → 3.0.6
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/lib/Nails.ts
CHANGED
|
@@ -98,7 +98,8 @@ export default class Nails {
|
|
|
98
98
|
async initializeModels() {
|
|
99
99
|
await this.loadModels(this.config.service.MODELS_ROOT);
|
|
100
100
|
await Promise.all(this.modelFinalizations.map((finalization) => finalization()));
|
|
101
|
-
|
|
101
|
+
// TODO: Implement a migration strategy
|
|
102
|
+
await this.sequelize.sync({alter: {drop: false}});
|
|
102
103
|
}
|
|
103
104
|
|
|
104
105
|
async startServer() {
|
|
@@ -174,9 +175,13 @@ export default class Nails {
|
|
|
174
175
|
const schema = modelModule.schema;
|
|
175
176
|
const options = modelModule.options;
|
|
176
177
|
const defer = modelModule.defer as (() => Promise<void>) | undefined;
|
|
178
|
+
const afterInitialize = modelModule.afterInitialize as (() => Promise<void>) | undefined;
|
|
177
179
|
if (modelModule.finalize) {
|
|
178
180
|
this.modelFinalizations.push(modelModule.finalize as () => Promise<void>);
|
|
179
181
|
}
|
|
182
|
+
if (modelModule.afterInitializeAll) {
|
|
183
|
+
this.modelFinalizations.push(modelModule.afterInitializeAll as () => Promise<void>);
|
|
184
|
+
}
|
|
180
185
|
this.modelMigrations.push(modelModule.migrate as () => Promise<void>);
|
|
181
186
|
|
|
182
187
|
modelClass.init(schema, { sequelize: this.sequelize, ...options });
|
|
@@ -185,6 +190,9 @@ export default class Nails {
|
|
|
185
190
|
if (defer) {
|
|
186
191
|
await defer();
|
|
187
192
|
}
|
|
193
|
+
if (afterInitialize) {
|
|
194
|
+
await afterInitialize();
|
|
195
|
+
}
|
|
188
196
|
await modelClass.sync();
|
|
189
197
|
}
|
|
190
198
|
else console.warn("No model found at:", absolutePath);
|
package/package.json
CHANGED