Skip to content

Commit 380e038

Browse files
authored
Merge pull request #1497 from Hirobreak/mig-logs
migration logs
2 parents 2dcf431 + d684814 commit 380e038

File tree

5 files changed

+29
-5
lines changed

5 files changed

+29
-5
lines changed

electron_app/src/database/DBEmigrations/20200123161254-multipleAccounts.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -458,7 +458,10 @@ module.exports = {
458458

459459
await transaction.commit();
460460
} catch (ex) {
461-
logger.error(ex);
461+
logger.error({
462+
message: 'Migration Multiple Accounts',
463+
error: ex
464+
});
462465
await transaction.rollback();
463466
throw new Error(ex.toString());
464467
}

electron_app/src/database/DBEmigrations/20200422145912-customerType.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
'use strict';
22
const { Table } = require('../DBEmodel');
3+
const logger = require('../../logger');
34

45
const migrateAccount = async (queryInterface, Sequelize, transaction) => {
56
const accountDef = await queryInterface.describeTable(Table.ACCOUNT, {
@@ -24,7 +25,10 @@ module.exports = {
2425
await migrateAccount(queryInterface, Sequelize, transaction);
2526
await transaction.commit();
2627
} catch (ex) {
27-
console.error(ex);
28+
logger.error({
29+
message: 'Migration Customer Type',
30+
error: ex
31+
});
2832
await transaction.rollback();
2933
throw new Error(ex.toString());
3034
}

electron_app/src/database/DBEmigrations/20200512111423_addBlockAllColumn.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
'use strict';
22
const { Table, Email } = require('../DBEmodel');
3+
const logger = require('../../logger');
34

45
const migrateBlockRemoteContent = async (
56
queryInterface,
@@ -79,7 +80,10 @@ module.exports = {
7980
await addUniqueIndexes(queryInterface, transaction);
8081
await transaction.commit();
8182
} catch (ex) {
82-
console.error(ex);
83+
logger.error({
84+
message: 'Migration Block All Column',
85+
error: ex
86+
});
8387
await transaction.rollback();
8488
throw new Error(ex.toString());
8589
}

electron_app/src/database/DBEmigrations/20200701180920_addDefaultAddressId.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
'use strict';
22
const { Table } = require('../DBEmodel');
3+
const logger = require('../../logger');
34

45
const migrateAccount = async (queryInterface, Sequelize, transaction) => {
56
const accountDef = await queryInterface.describeTable(Table.ACCOUNT, {
@@ -24,7 +25,10 @@ module.exports = {
2425
await migrateAccount(queryInterface, Sequelize, transaction);
2526
await transaction.commit();
2627
} catch (ex) {
27-
console.error(ex);
28+
logger.error({
29+
message: 'Migration Default Address',
30+
error: ex
31+
});
2832
await transaction.rollback();
2933
throw new Error(ex.toString());
3034
}

electron_app/src/database/DBEmodel.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -559,6 +559,10 @@ const initDatabaseEncrypted = async (
559559
}
560560
});
561561

562+
logger.info(
563+
`Database Current Version : ${JSON.stringify(localVersion.toJSON())}`
564+
);
565+
562566
const emailDef = await Email.describe();
563567
if (emailDef.accountId && localVersion.value === CURRENT_VERSION) return;
564568

@@ -592,6 +596,8 @@ const initDatabaseEncrypted = async (
592596
break;
593597
}
594598

599+
logger.info(`Migrations to perform : ${migrationFiles.toString()}`);
600+
595601
try {
596602
const migrationPath = path.join(__dirname, '/DBEmigrations');
597603
const migrator = new umzug({
@@ -619,7 +625,10 @@ const initDatabaseEncrypted = async (
619625
}
620626
);
621627
} catch (ex) {
622-
logger.error(ex);
628+
logger.error({
629+
message: 'Migrating Database',
630+
error: ex
631+
});
623632
}
624633
};
625634

0 commit comments

Comments
 (0)