Sync db tables before initializing the constraints.
This commit is contained in:
parent
9c5db733fd
commit
61f2cde690
1 changed files with 8 additions and 13 deletions
21
src/db/Db.ts
21
src/db/Db.ts
|
@ -112,20 +112,15 @@ class Db {
|
||||||
public async sync() {
|
public async sync() {
|
||||||
console.log('Syncing databases');
|
console.log('Syncing databases');
|
||||||
|
|
||||||
const gpsData = this.GPSData();
|
for (const modelName of ['GPSData', 'Role', 'User', 'UserRole', 'UserSession']) {
|
||||||
const role = this.Role();
|
const model = (this as any)[modelName]();
|
||||||
const user = this.User();
|
process.stdout.write(` [⌛] Syncing ${model.name}`);
|
||||||
const userRole = this.UserRole();
|
await model.sync();
|
||||||
const userSession = this.UserSession();
|
await this.appDb.sync();
|
||||||
|
process.stdout.write(`\r [✅] Synced ${model.name} \n`);
|
||||||
|
}
|
||||||
|
|
||||||
this.initConstraints();
|
this.initConstraints();
|
||||||
|
|
||||||
await gpsData.sync();
|
|
||||||
await role.sync();
|
|
||||||
await user.sync();
|
|
||||||
await userRole.sync();
|
|
||||||
await userSession.sync();
|
|
||||||
|
|
||||||
await this.appDb.sync();
|
|
||||||
console.log('Database sync completed');
|
console.log('Database sync completed');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue