Skip to content

Commit

Permalink
feat: consolidate migrations and model
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael.Taylor committed Dec 15, 2021
1 parent 5b1fcba commit 72200ad
Show file tree
Hide file tree
Showing 36 changed files with 358 additions and 714 deletions.
58 changes: 5 additions & 53 deletions migrations/20211201194416-create-qualification.cjs
Original file line number Diff line number Diff line change
@@ -1,60 +1,12 @@
'use strict';

const modelTypes = require('../src/models/qualifications/qualifications.modeltypes.cjs');

module.exports = {
up: async (queryInterface, Sequelize) => {
await queryInterface.createTable('Qualifications', {
id: {
allowNull: false,
autoIncrement: true,
primaryKey: true,
type: Sequelize.INTEGER,
},
projectId: {
type: Sequelize.NUMBER,
},
qualificationId: {
type: Sequelize.NUMBER,
},
qualificationLink: {
type: Sequelize.STRING,
},
type: {
type: Sequelize.STRING,
},
label: {
type: Sequelize.STRING,
},
creditingPeriodStartDate: {
type: Sequelize.DATE,
},
creditingPeriodEndDate: {
type: Sequelize.DATE,
},
validityStartDate: {
type: Sequelize.DATE,
},
validityEndDate: {
type: Sequelize.DATE,
},
unitQuantity: {
type: Sequelize.NUMBER,
},
owner: {
type: Sequelize.STRING,
},
unitId: {
type: Sequelize.NUMBER,
},
createdAt: {
allowNull: false,
type: Sequelize.DATE,
},
updatedAt: {
allowNull: false,
type: Sequelize.DATE,
},
});
await queryInterface.createTable('qualifications', modelTypes);
},
down: async (queryInterface, Sequelize) => {
await queryInterface.dropTable('Qualifications');
await queryInterface.dropTable('qualifications');
},
};
41 changes: 7 additions & 34 deletions migrations/20211201194449-create-related-project.cjs
Original file line number Diff line number Diff line change
@@ -1,39 +1,12 @@
'use strict';

const modelTypes = require('../src/models/related-projects/related-projects.modeltypes.cjs');

module.exports = {
up: async (queryInterface, Sequelize) => {
await queryInterface.createTable('RelatedProjects', {
id: {
allowNull: false,
autoIncrement: true,
primaryKey: true,
type: Sequelize.INTEGER
},
relatedProjectType: {
type: Sequelize.STRING
},
registry: {
type: Sequelize.STRING
},
note: {
type: Sequelize.STRING
},
owner: {
type: Sequelize.STRING
},
projectId: {
type: Sequelize.NUMBER
},
createdAt: {
allowNull: false,
type: Sequelize.DATE
},
updatedAt: {
allowNull: false,
type: Sequelize.DATE
}
});
await queryInterface.createTable('relatedProjects', modelTypes);
},
down: async (queryInterface, Sequelize) => {
await queryInterface.dropTable('RelatedProjects');
}
};
await queryInterface.dropTable('relatedProjects');
},
};
46 changes: 5 additions & 41 deletions migrations/20211201194541-create-vintage.cjs
Original file line number Diff line number Diff line change
@@ -1,48 +1,12 @@
'use strict';

const modelTypes = require('../src/models/vintages/vintages.modeltypes.cjs');

module.exports = {
up: async (queryInterface, Sequelize) => {
await queryInterface.createTable('Vintages', {
id: {
allowNull: false,
autoIncrement: true,
primaryKey: true,
type: Sequelize.INTEGER,
},
startDate: {
type: Sequelize.DATE,
},
endDate: {
type: Sequelize.DATE,
},
verificationApproach: {
type: Sequelize.STRING,
},
verificationDate: {
type: Sequelize.DATE,
},
verificationBody: {
type: Sequelize.STRING,
},
owner: {
type: Sequelize.STRING,
},
projectId: {
type: Sequelize.NUMBER,
},
UnitId: {
type: Sequelize.NUMBER,
},
createdAt: {
allowNull: false,
type: Sequelize.DATE,
},
updatedAt: {
allowNull: false,
type: Sequelize.DATE,
},
});
await queryInterface.createTable('vintages', modelTypes);
},
down: async (queryInterface, Sequelize) => {
await queryInterface.dropTable('Vintages');
await queryInterface.dropTable('vintages');
},
};
76 changes: 5 additions & 71 deletions migrations/20211201194652-create-unit.cjs
Original file line number Diff line number Diff line change
@@ -1,78 +1,12 @@
'use strict';

const modelTypes = require('../src/models/units/units.modeltypes.cjs');

module.exports = {
up: async (queryInterface, Sequelize) => {
await queryInterface.createTable('Units', {
id: {
allowNull: false,
autoIncrement: true,
primaryKey: true,
type: Sequelize.INTEGER,
},
uuid: {
type: Sequelize.STRING,
},
ProjectId: {
type: Sequelize.STRING,
},
owner: {
type: Sequelize.STRING,
},
buyer: {
type: Sequelize.STRING,
},
registry: {
type: Sequelize.STRING,
},
blockIdentifier: {
type: Sequelize.STRING,
},
identifier: {
type: Sequelize.STRING,
},
qualificationId: {
type: Sequelize.NUMBER,
},
unitType: {
type: Sequelize.STRING,
},
unitCount: {
type: Sequelize.NUMBER,
},
unitStatus: {
type: Sequelize.STRING,
},
unitStatusDate: {
type: Sequelize.DATE,
},
transactionType: {
type: Sequelize.STRING,
},
unitIssuanceLocation: {
type: Sequelize.STRING,
},
unitLink: {
type: Sequelize.STRING,
},
correspondingAdjustment: {
type: Sequelize.STRING,
},
unitTag: {
type: Sequelize.STRING,
},
vintageId: {
type: Sequelize.NUMBER,
},
createdAt: {
allowNull: false,
type: Sequelize.DATE,
},
updatedAt: {
allowNull: false,
type: Sequelize.DATE,
},
});
await queryInterface.createTable('units', modelTypes);
},
down: async (queryInterface, Sequelize) => {
await queryInterface.dropTable('Units');
await queryInterface.dropTable('units');
},
};
24 changes: 12 additions & 12 deletions migrations/20211201194720-create-party.cjs
Original file line number Diff line number Diff line change
@@ -1,36 +1,36 @@
'use strict';
module.exports = {
up: async (queryInterface, Sequelize) => {
await queryInterface.createTable('Parties', {
await queryInterface.createTable('parties', {
id: {
allowNull: false,
autoIncrement: true,
primaryKey: true,
type: Sequelize.INTEGER
type: Sequelize.INTEGER,
},
name: {
type: Sequelize.STRING
type: Sequelize.STRING,
},
country: {
type: Sequelize.STRING
type: Sequelize.STRING,
},
registry: {
type: Sequelize.STRING
type: Sequelize.STRING,
},
owner: {
type: Sequelize.STRING
type: Sequelize.STRING,
},
createdAt: {
allowNull: false,
type: Sequelize.DATE
type: Sequelize.DATE,
},
updatedAt: {
allowNull: false,
type: Sequelize.DATE
}
type: Sequelize.DATE,
},
});
},
down: async (queryInterface, Sequelize) => {
await queryInterface.dropTable('Parties');
}
};
await queryInterface.dropTable('parties');
},
};
44 changes: 7 additions & 37 deletions migrations/20211201194803-create-project-rating.cjs
Original file line number Diff line number Diff line change
@@ -1,42 +1,12 @@
'use strict';

const modelTypes = require('../src/models/ratings/ratings.modeltypes.cjs');

module.exports = {
up: async (queryInterface, Sequelize) => {
await queryInterface.createTable('ProjectRatings', {
id: {
allowNull: false,
autoIncrement: true,
primaryKey: true,
type: Sequelize.INTEGER
},
ratingType: {
type: Sequelize.STRING
},
rating: {
type: Sequelize.NUMBER
},
link: {
type: Sequelize.STRING
},
scale: {
type: Sequelize.STRING
},
owner: {
type: Sequelize.STRING
},
projectId: {
type: Sequelize.NUMBER
},
createdAt: {
allowNull: false,
type: Sequelize.DATE
},
updatedAt: {
allowNull: false,
type: Sequelize.DATE
}
});
await queryInterface.createTable('projectRatings', modelTypes);
},
down: async (queryInterface, Sequelize) => {
await queryInterface.dropTable('ProjectRatings');
}
};
await queryInterface.dropTable('projectRatings');
},
};
35 changes: 7 additions & 28 deletions migrations/20211201194914-create-co-benefit.cjs
Original file line number Diff line number Diff line change
@@ -1,33 +1,12 @@
'use strict';

const modelTypes = require('../src/models/co-benefits/co-benifets.modeltypes.cjs');

module.exports = {
up: async (queryInterface, Sequelize) => {
await queryInterface.createTable('CoBenefits', {
id: {
allowNull: false,
autoIncrement: true,
primaryKey: true,
type: Sequelize.INTEGER
},
benefit: {
type: Sequelize.STRING
},
owner: {
type: Sequelize.STRING
},
projectId: {
type: Sequelize.NUMBER
},
createdAt: {
allowNull: false,
type: Sequelize.DATE
},
updatedAt: {
allowNull: false,
type: Sequelize.DATE
}
});
await queryInterface.createTable('coBenefits', modelTypes);
},
down: async (queryInterface, Sequelize) => {
await queryInterface.dropTable('CoBenefits');
}
};
await queryInterface.dropTable('coBenefits');
},
};
Loading

0 comments on commit 72200ad

Please sign in to comment.