From 5c0fdad56307daadb036edc802289123e734190c Mon Sep 17 00:00:00 2001 From: Mike Keen Date: Sun, 5 Dec 2021 01:10:10 +0000 Subject: [PATCH] feat: bring models in line with migrations --- models/project.js | 47 +++++++++++++++++++++------------------ models/projectlocation.js | 11 +++++---- models/projectrating.js | 15 ++++++++----- models/qualification.js | 20 +++++++++++------ models/relatedproject.js | 13 ++++++----- models/unit.js | 42 +++++++++++++++++----------------- models/vintage.js | 17 ++++++++------ 7 files changed, 93 insertions(+), 72 deletions(-) diff --git a/models/project.js b/models/project.js index d9fbe66f..f4131bf0 100644 --- a/models/project.js +++ b/models/project.js @@ -14,28 +14,31 @@ module.exports = (sequelize, DataTypes) => { } }; Project.init({ - currentRegistry: DataTypes.STRING, - registryOfOrigin: DataTypes.STRING, - originProjectId: DataTypes.NUMBER, - program: DataTypes.STRING, - warehouseProjectId: DataTypes.NUMBER, - projectName: DataTypes.STRING, - projectLink: DataTypes.STRING, - projectDeveloper: DataTypes.STRING, - sector: DataTypes.STRING, - projectType: DataTypes.STRING, - coveredByNDC: DataTypes.STRING, - NDCLinkage: DataTypes.STRING, - projectStatus: DataTypes.STRING, - projectStatusDate: DataTypes.DATE, - unitMetric: DataTypes.STRING, - methodology: DataTypes.STRING, - methodologyVersion: DataTypes.STRING, - validationApproach: DataTypes.STRING, - validationDate: DataTypes.DATE, - projectTag: DataTypes.STRING, - estimatedAnnualAverageEmmisionReduction: DataTypes.STRING, - owner: DataTypes.STRING + id: Sequelize.INTEGER, + currentRegistry: Sequelize.STRING, + registryOfOrigin: Sequelize.STRING, + originProjectId: Sequelize.NUMBER, + program: Sequelize.STRING, + warehouseProjectId: Sequelize.NUMBER, + projectName: Sequelize.STRING, + projectLink: Sequelize.STRING, + projectDeveloper: Sequelize.STRING, + sector: Sequelize.STRING, + projectType: Sequelize.STRING, + coveredByNDC: Sequelize.STRING, + NDCLinkage: Sequelize.STRING, + projectStatus: Sequelize.STRING, + projectStatusDate: Sequelize.DATE, + unitMetric: Sequelize.STRING, + methodology: Sequelize.STRING, + methodologyVersion: Sequelize.STRING, + validationApproach: Sequelize.STRING, + validationDate: Sequelize.DATE, + projectTag: Sequelize.STRING, + estimatedAnnualAverageEmmisionReduction: Sequelize.STRING, + owner: Sequelize.STRING, + createdAt: Sequelize.DATE, + updatedAt: Sequelize.DATE, }, { sequelize, modelName: 'Project', diff --git a/models/projectlocation.js b/models/projectlocation.js index e22415a2..92bc9158 100644 --- a/models/projectlocation.js +++ b/models/projectlocation.js @@ -14,10 +14,13 @@ module.exports = (sequelize, DataTypes) => { } }; ProjectLocation.init({ - countryRegion: DataTypes.STRING, - country: DataTypes.STRING, - owner: DataTypes.STRING, - projectId: DataTypes.NUMBER + id: Sequelize.INTEGER, + countryRegion: Sequelize.STRING, + country: Sequelize.STRING, + owner: Sequelize.STRING, + projectId: Sequelize.NUMBER, + createdAt: Sequelize.DATE, + updatedAt: Sequelize.DATE, }, { sequelize, modelName: 'ProjectLocation', diff --git a/models/projectrating.js b/models/projectrating.js index 77185730..0e0d94f3 100644 --- a/models/projectrating.js +++ b/models/projectrating.js @@ -14,12 +14,15 @@ module.exports = (sequelize, DataTypes) => { } }; ProjectRating.init({ - ratingType: DataTypes.STRING, - rating: DataTypes.NUMBER, - link: DataTypes.STRING, - scale: DataTypes.STRING, - owner: DataTypes.STRING, - projectId: DataTypes.NUMBER + id: Sequelize.INTEGER, + ratingType: Sequelize.STRING, + rating: Sequelize.NUMBER, + link: Sequelize.STRING, + scale: Sequelize.STRING, + owner: Sequelize.STRING, + projectId: Sequelize.NUMBER, + createdAt: Sequelize.DATE, + updatedAt: Sequelize.DATE, }, { sequelize, modelName: 'ProjectRating', diff --git a/models/qualification.js b/models/qualification.js index d90dd6a3..1066a928 100644 --- a/models/qualification.js +++ b/models/qualification.js @@ -14,13 +14,19 @@ module.exports = (sequelize, DataTypes) => { } }; Qualification.init({ - projectId: DataTypes.NUMBER, - type: DataTypes.STRING, - label: DataTypes.STRING, - creditingPeriodStartDate: DataTypes.DATE, - creditingPeriodEndDate: DataTypes.DATE, - owner: DataTypes.STRING, - unitId: DataTypes.NUMBER + id: Sequelize.INTEGER, + projectId: Sequelize.NUMBER, + type: Sequelize.STRING, + label: Sequelize.STRING, + creditingPeriodStartDate: Sequelize.DATE, + creditingPeriodEndDate: Sequelize.DATE, + validityStartDate: Sequelize.DATE, + validityEndDate: Sequelize.DATE, + unitQuantity: Sequelize.NUMBER, + owner: Sequelize.STRING, + unitId: Sequelize.NUMBER, + createdAt: Sequelize.DATE, + updatedAt: Sequelize.DATE, }, { sequelize, modelName: 'Qualification', diff --git a/models/relatedproject.js b/models/relatedproject.js index 18d2a33c..2e92efc6 100644 --- a/models/relatedproject.js +++ b/models/relatedproject.js @@ -14,11 +14,14 @@ module.exports = (sequelize, DataTypes) => { } }; RelatedProject.init({ - relatedProjectType: DataTypes.STRING, - registry: DataTypes.STRING, - note: DataTypes.STRING, - owner: DataTypes.STRING, - projectId: DataTypes.NUMBER + id: Sequelize.INTEGER, + relatedProjectType: Sequelize.STRING, + registry: Sequelize.STRING, + note: Sequelize.STRING, + owner: Sequelize.STRING, + projectId: Sequelize.NUMBER, + createdAt: Sequelize.DATE, + updatedAt: Sequelize.DATE }, { sequelize, modelName: 'RelatedProject', diff --git a/models/unit.js b/models/unit.js index 24696ac1..a3710bbd 100644 --- a/models/unit.js +++ b/models/unit.js @@ -14,27 +14,27 @@ module.exports = (sequelize, DataTypes) => { } }; Unit.init({ - owner: DataTypes.STRING, - buyer: DataTypes.STRING, - registry: DataTypes.STRING, - blockIdentifier: DataTypes.STRING, - identifier: DataTypes.STRING, - qualificationId: DataTypes.NUMBER, - unitType: DataTypes.STRING, - unitCount: DataTypes.NUMBER, - unitStatus: DataTypes.STRING, - unitStatusDate: DataTypes.DATE, - transactionType: DataTypes.STRING, - unitIssuanceLocation: DataTypes.STRING, - unitLink: DataTypes.STRING, - correspondingAdjustment: DataTypes.STRING, - unitTag: DataTypes.STRING, - vintageId: DataTypes.NUMBER, - qualificationId: DataTypes.NUMBER, - owner: DataTypes.STRING - }, { - sequelize, - modelName: 'Unit', + id: Sequelize.INTEGER, + owner: Sequelize.STRING, + buyer: Sequelize.STRING, + registry: Sequelize.STRING, + blockIdentifier: Sequelize.STRING, + identifier: Sequelize.STRING, + qualificationId: Sequelize.NUMBER, + unitType: Sequelize.STRING, + unitCount: Sequelize.NUMBER, + unitStatus: Sequelize.STRING, + unitStatusDate: Sequelize.DATE, + transactionType: Sequelize.STRING, + unitIssuanceLocation: Sequelize.STRING, + unitLink: Sequelize.STRING, + correspondingAdjustment: Sequelize.STRING, + unitTag: Sequelize.STRING, + vintageId: Sequelize.NUMBER, + createdAt: Sequelize.DATE, + updatedAt: Sequelize.DATE}, { + sequelize, + modelName: 'Unit', }); return Unit; }; \ No newline at end of file diff --git a/models/vintage.js b/models/vintage.js index d30057e5..e43a2a21 100644 --- a/models/vintage.js +++ b/models/vintage.js @@ -14,13 +14,16 @@ module.exports = (sequelize, DataTypes) => { } }; Vintage.init({ - startDate: DataTypes.DATE, - endDate: DataTypes.DATE, - verificationApproach: DataTypes.STRING, - verificationDate: DataTypes.DATE, - verificationBody: DataTypes.STRING, - owner: DataTypes.STRING, - projectId: DataTypes.NUMBER + id: Sequelize.INTEGER, + startDate: Sequelize.DATE, + endDate: Sequelize.DATE, + verificationApproach: Sequelize.STRING, + verificationDate: Sequelize.DATE, + verificationBody: Sequelize.STRING, + owner: Sequelize.STRING, + projectId: Sequelize.NUMBER, + createdAt: Sequelize.DATE, + updatedAt: Sequelize.DATE, }, { sequelize, modelName: 'Vintage',