Skip to content

Commit

Permalink
fix: several mysql compatibility fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelTaylor3D committed Apr 17, 2023
1 parent 306b0fd commit 8418710
Show file tree
Hide file tree
Showing 27 changed files with 694 additions and 510 deletions.
16 changes: 8 additions & 8 deletions src/database/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,16 @@ export const safeMirrorDbHandler = (callback) => {
try {
sequelizeMirror
.authenticate()
.then(() => {
callback();
.then(async () => {
try {
console.log('Sending Cmd to Mirror');
await callback();
} catch (e) {
logger.error(`mirror_error:${e.message}`);
}
})
.catch(() => {
if (
getConfig().MIRROR_DB.DB_HOST &&
getConfig().MIRROR_DB.DB_HOST !== ''
) {
logger.info('Mirror DB not connected');
}
logger.info('Mirror DB not connected');
});
} catch (error) {
logger.error(
Expand Down
127 changes: 67 additions & 60 deletions src/database/migrations/20211201194416-create-label.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,68 +4,75 @@ import { uuid as uuidv4 } from 'uuidv4';

export default {
up: async (queryInterface, Sequelize) => {
await queryInterface.createTable('labels', {
id: {
type: Sequelize.STRING,
allowNull: false,
unique: true,
defaultValue: () => uuidv4(),
primaryKey: true,
await queryInterface.createTable(
'labels',
{
id: {
type: Sequelize.STRING,
allowNull: false,
unique: true,
defaultValue: () => uuidv4(),
primaryKey: true,
},
warehouseProjectId: {
type: Sequelize.STRING,
required: true,
},
// The orgUid is the singeltonId of the
// organizations tables on the datalayer
orgUid: {
type: Sequelize.STRING,
required: true,
},
label: {
type: Sequelize.STRING,
require: true,
},
labelType: {
type: Sequelize.STRING,
require: true,
},
creditingPeriodStartDate: {
type: Sequelize.DATE,
require: true,
},
creditingPeriodEndDate: {
type: Sequelize.DATE,
require: true,
},
validityPeriodStartDate: {
type: Sequelize.DATE,
require: true,
},
validityPeriodEndDate: {
type: Sequelize.DATE,
require: true,
},
unitQuantity: {
type: Sequelize.INTEGER,
require: true,
},
labelLink: {
type: Sequelize.STRING,
require: true,
},
timeStaged: {
type: Sequelize.STRING,
},
createdAt: {
type: Sequelize.DATE,
defaultValue: Sequelize.NOW,
},
updatedAt: {
type: Sequelize.DATE,
defaultValue: Sequelize.NOW,
},
},
warehouseProjectId: {
type: Sequelize.STRING,
required: true,
{
charset: 'utf8mb4',
collate: 'utf8mb4_general_ci',
},
// The orgUid is the singeltonId of the
// organizations tables on the datalayer
orgUid: {
type: Sequelize.STRING,
required: true,
},
label: {
type: Sequelize.STRING,
require: true,
},
labelType: {
type: Sequelize.STRING,
require: true,
},
creditingPeriodStartDate: {
type: Sequelize.DATE,
require: true,
},
creditingPeriodEndDate: {
type: Sequelize.DATE,
require: true,
},
validityPeriodStartDate: {
type: Sequelize.DATE,
require: true,
},
validityPeriodEndDate: {
type: Sequelize.DATE,
require: true,
},
unitQuantity: {
type: Sequelize.INTEGER,
require: true,
},
labelLink: {
type: Sequelize.STRING,
require: true,
},
timeStaged: {
type: Sequelize.STRING,
},
createdAt: {
type: Sequelize.DATE,
defaultValue: Sequelize.NOW,
},
updatedAt: {
type: Sequelize.DATE,
defaultValue: Sequelize.NOW,
},
});
);
},
down: async (queryInterface) => {
await queryInterface.dropTable('labels');
Expand Down
73 changes: 40 additions & 33 deletions src/database/migrations/20211201194449-create-related-project.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,41 +4,48 @@ import { uuid as uuidv4 } from 'uuidv4';

export default {
up: async (queryInterface, Sequelize) => {
await queryInterface.createTable('relatedProjects', {
id: {
type: Sequelize.STRING,
allowNull: false,
unique: true,
defaultValue: () => uuidv4(),
primaryKey: true,
await queryInterface.createTable(
'relatedProjects',
{
id: {
type: Sequelize.STRING,
allowNull: false,
unique: true,
defaultValue: () => uuidv4(),
primaryKey: true,
},
warehouseProjectId: {
type: Sequelize.STRING,
required: true,
},
// The orgUid is the singeltonId of the
// organizations tables on the datalayer
orgUid: {
type: Sequelize.STRING,
required: true,
},
relatedProjectId: {
type: Sequelize.STRING,
},
relationshipType: Sequelize.STRING,
registry: Sequelize.STRING,
timeStaged: {
type: Sequelize.STRING,
},
createdAt: {
type: Sequelize.DATE,
defaultValue: Sequelize.NOW,
},
updatedAt: {
type: Sequelize.DATE,
defaultValue: Sequelize.NOW,
},
},
warehouseProjectId: {
type: Sequelize.STRING,
required: true,
{
charset: 'utf8mb4',
collate: 'utf8mb4_general_ci',
},
// The orgUid is the singeltonId of the
// organizations tables on the datalayer
orgUid: {
type: Sequelize.STRING,
required: true,
},
relatedProjectId: {
type: Sequelize.STRING,
},
relationshipType: Sequelize.STRING,
registry: Sequelize.STRING,
timeStaged: {
type: Sequelize.STRING,
},
createdAt: {
type: Sequelize.DATE,
defaultValue: Sequelize.NOW,
},
updatedAt: {
type: Sequelize.DATE,
defaultValue: Sequelize.NOW,
},
});
);
},
down: async (queryInterface) => {
await queryInterface.dropTable('relatedProjects');
Expand Down
101 changes: 54 additions & 47 deletions src/database/migrations/20211201194541-create-issuance.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,55 +4,62 @@ import { uuid as uuidv4 } from 'uuidv4';

export default {
up: async (queryInterface, Sequelize) => {
await queryInterface.createTable('issuances', {
id: {
type: Sequelize.STRING,
allowNull: false,
unique: true,
defaultValue: () => uuidv4(),
primaryKey: true,
await queryInterface.createTable(
'issuances',
{
id: {
type: Sequelize.STRING,
allowNull: false,
unique: true,
defaultValue: () => uuidv4(),
primaryKey: true,
},
orgUid: {
type: Sequelize.STRING,
required: true,
},
warehouseProjectId: {
type: Sequelize.STRING,
required: true,
},
startDate: {
type: Sequelize.DATE,
required: true,
},
endDate: {
type: Sequelize.DATE,
required: true,
},
verificationApproach: {
type: Sequelize.STRING,
required: true,
},
verificationReportDate: {
type: Sequelize.DATE,
required: true,
},
verificationBody: {
type: Sequelize.STRING,
required: true,
},
timeStaged: {
type: Sequelize.STRING,
},
createdAt: {
type: Sequelize.DATE,
defaultValue: Sequelize.NOW,
},
updatedAt: {
type: Sequelize.DATE,
defaultValue: Sequelize.NOW,
allowNull: false,
},
},
orgUid: {
type: Sequelize.STRING,
required: true,
{
charset: 'utf8mb4',
collate: 'utf8mb4_general_ci',
},
warehouseProjectId: {
type: Sequelize.STRING,
required: true,
},
startDate: {
type: Sequelize.DATE,
required: true,
},
endDate: {
type: Sequelize.DATE,
required: true,
},
verificationApproach: {
type: Sequelize.STRING,
required: true,
},
verificationReportDate: {
type: Sequelize.DATE,
required: true,
},
verificationBody: {
type: Sequelize.STRING,
required: true,
},
timeStaged: {
type: Sequelize.STRING,
},
createdAt: {
type: Sequelize.DATE,
defaultValue: Sequelize.NOW,
},
updatedAt: {
type: Sequelize.DATE,
defaultValue: Sequelize.NOW,
allowNull: false,
},
});
);
},
down: async (queryInterface) => {
await queryInterface.dropTable('issuances');
Expand Down
Loading

0 comments on commit 8418710

Please sign in to comment.