Skip to content

Commit

Permalink
feat: added sqlite db and migrated tables
Browse files Browse the repository at this point in the history
  • Loading branch information
frantzarty committed Dec 1, 2021
1 parent bdbe84e commit bac2adc
Show file tree
Hide file tree
Showing 20 changed files with 326 additions and 12 deletions.
2 changes: 1 addition & 1 deletion config/config.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"development": {
"dialect": "sqlite",
"storage": "data.sqlite3"
"storage": "./data.sqlite3"
},
"test": {
"username": "root",
Expand Down
Binary file added data.sqlite3
Binary file not shown.
45 changes: 45 additions & 0 deletions migrations/20211201194416-create-qualification.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
'use strict';
module.exports = {
up: async (queryInterface, Sequelize) => {
await queryInterface.createTable('Qualifications', {
id: {
allowNull: false,
autoIncrement: true,
primaryKey: true,
type: Sequelize.INTEGER
},
projectId: {
type: Sequelize.NUMBER
},
type: {
type: Sequelize.STRING
},
label: {
type: Sequelize.STRING
},
creditingPeriodStartDate: {
type: Sequelize.DATE
},
creditingPeriodEndDate: {
type: Sequelize.DATE
},
owner: {
type: Sequelize.STRING
},
unitId: {
type: Sequelize.NUMBER
},
createdAt: {
allowNull: false,
type: Sequelize.DATE
},
updatedAt: {
allowNull: false,
type: Sequelize.DATE
}
});
},
down: async (queryInterface, Sequelize) => {
await queryInterface.dropTable('Qualifications');
}
};
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@ module.exports = {
note: {
type: Sequelize.STRING
},
owner: {
type: Sequelize.STRING
},
projectId: {
type: Sequelize.NUMBER
},
createdAt: {
allowNull: false,
type: Sequelize.DATE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@ module.exports = {
verificationBody: {
type: Sequelize.STRING
},
owner: {
type: Sequelize.STRING
},
projectId: {
type: Sequelize.NUMBER
},
createdAt: {
allowNull: false,
type: Sequelize.DATE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,15 @@ module.exports = {
unitTag: {
type: Sequelize.STRING
},
vintageId: {
type: Sequelize.NUMBER
},
qualificationId: {
type: Sequelize.NUMBER
},
owner: {
type: Sequelize.STRING
},
createdAt: {
allowNull: false,
type: Sequelize.DATE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ module.exports = {
registry: {
type: Sequelize.STRING
},
owner: {
type: Sequelize.STRING
},
createdAt: {
allowNull: false,
type: Sequelize.DATE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@ module.exports = {
scale: {
type: Sequelize.STRING
},
owner: {
type: Sequelize.STRING
},
projectId: {
type: Sequelize.NUMBER
},
createdAt: {
allowNull: false,
type: Sequelize.DATE
Expand Down
33 changes: 33 additions & 0 deletions migrations/20211201194914-create-co-benefit.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
'use strict';
module.exports = {
up: async (queryInterface, Sequelize) => {
await queryInterface.createTable('CoBenefits', {
id: {
allowNull: false,
autoIncrement: true,
primaryKey: true,
type: Sequelize.INTEGER
},
benfit: {
type: Sequelize.STRING
},
owner: {
type: Sequelize.STRING
},
projectId: {
type: Sequelize.NUMBER
},
createdAt: {
allowNull: false,
type: Sequelize.DATE
},
updatedAt: {
allowNull: false,
type: Sequelize.DATE
}
});
},
down: async (queryInterface, Sequelize) => {
await queryInterface.dropTable('CoBenefits');
}
};
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,15 @@ module.exports = {
countryRegion: {
type: Sequelize.STRING
},
hostCountry: {
country: {
type: Sequelize.STRING
},
owner: {
type: Sequelize.STRING
},
projectId: {
type: Sequelize.NUMBER
},
createdAt: {
allowNull: false,
type: Sequelize.DATE
Expand Down
90 changes: 90 additions & 0 deletions migrations/20211201195550-create-project.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
'use strict';
module.exports = {
up: async (queryInterface, Sequelize) => {
await queryInterface.createTable('Projects', {
id: {
allowNull: false,
autoIncrement: true,
primaryKey: true,
type: Sequelize.INTEGER
},
currentRegistry: {
type: Sequelize.STRING
},
registryOfOrigin: {
type: Sequelize.STRING
},
originProjectId: {
type: Sequelize.NUMBER
},
program: {
type: Sequelize.STRING
},
warehouseProjectId: {
type: Sequelize.NUMBER
},
projectName: {
type: Sequelize.STRING
},
projectLink: {
type: Sequelize.STRING
},
projectDeveloper: {
type: Sequelize.STRING
},
sector: {
type: Sequelize.STRING
},
projectType: {
type: Sequelize.STRING
},
coveredByNDC: {
type: Sequelize.STRING
},
NDCLinkage: {
type: Sequelize.STRING
},
projectStatus: {
type: Sequelize.STRING
},
projectStatusDate: {
type: Sequelize.DATE
},
unitMetric: {
type: Sequelize.STRING
},
methodology: {
type: Sequelize.STRING
},
methodologyVersion: {
type: Sequelize.STRING
},
validationApproach: {
type: Sequelize.STRING
},
validationDate: {
type: Sequelize.DATE
},
projectTag: {
type: Sequelize.STRING
},
estimatedAnnualAverageEmmisionReduction: {
type: Sequelize.STRING
},
owner: {
type: Sequelize.STRING
},
createdAt: {
allowNull: false,
type: Sequelize.DATE
},
updatedAt: {
allowNull: false,
type: Sequelize.DATE
}
});
},
down: async (queryInterface, Sequelize) => {
await queryInterface.dropTable('Projects');
}
};
25 changes: 25 additions & 0 deletions models/cobenefit.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
'use strict';
const {
Model
} = require('sequelize');
module.exports = (sequelize, DataTypes) => {
class CoBenefit extends Model {
/**
* Helper method for defining associations.
* This method is not a part of Sequelize lifecycle.
* The `models/index` file will call this method automatically.
*/
static associate(models) {
// define association here
}
};
CoBenefit.init({
benfit: DataTypes.STRING,
owner: DataTypes.STRING,
projectId: DataTypes.NUMBER
}, {
sequelize,
modelName: 'CoBenefit',
});
return CoBenefit;
};
3 changes: 2 additions & 1 deletion models/party.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ module.exports = (sequelize, DataTypes) => {
Party.init({
name: DataTypes.STRING,
country: DataTypes.STRING,
registry: DataTypes.STRING
registry: DataTypes.STRING,
owner: DataTypes.STRING
}, {
sequelize,
modelName: 'Party',
Expand Down
44 changes: 44 additions & 0 deletions models/project.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
'use strict';
const {
Model
} = require('sequelize');
module.exports = (sequelize, DataTypes) => {
class Project extends Model {
/**
* Helper method for defining associations.
* This method is not a part of Sequelize lifecycle.
* The `models/index` file will call this method automatically.
*/
static associate(models) {
// define association here
}
};
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
}, {
sequelize,
modelName: 'Project',
});
return Project;
};
4 changes: 3 additions & 1 deletion models/projectlocation.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ module.exports = (sequelize, DataTypes) => {
};
ProjectLocation.init({
countryRegion: DataTypes.STRING,
hostCountry: DataTypes.STRING
country: DataTypes.STRING,
owner: DataTypes.STRING,
projectId: DataTypes.NUMBER
}, {
sequelize,
modelName: 'ProjectLocation',
Expand Down
12 changes: 7 additions & 5 deletions models/projectratings.js → models/projectrating.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const {
Model
} = require('sequelize');
module.exports = (sequelize, DataTypes) => {
class ProjectRatings extends Model {
class ProjectRating extends Model {
/**
* Helper method for defining associations.
* This method is not a part of Sequelize lifecycle.
Expand All @@ -13,14 +13,16 @@ module.exports = (sequelize, DataTypes) => {
// define association here
}
};
ProjectRatings.init({
ProjectRating.init({
ratingType: DataTypes.STRING,
rating: DataTypes.NUMBER,
link: DataTypes.STRING,
scale: DataTypes.STRING
scale: DataTypes.STRING,
owner: DataTypes.STRING,
projectId: DataTypes.NUMBER
}, {
sequelize,
modelName: 'ProjectRatings',
modelName: 'ProjectRating',
});
return ProjectRatings;
return ProjectRating;
};
Loading

0 comments on commit bac2adc

Please sign in to comment.