Skip to content

Commit

Permalink
Merge pull request #220 from Chia-Network/feature/refactor6
Browse files Browse the repository at this point in the history
feat: update datamodel
  • Loading branch information
MichaelTaylor3D authored Jan 26, 2022
2 parents 379f9dd + ecbd3af commit f309cb6
Show file tree
Hide file tree
Showing 46 changed files with 517 additions and 275 deletions.
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"files.eol": "\n"
}
6 changes: 3 additions & 3 deletions migrations/20211201194914-create-co-benefit.cjs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
'use strict';

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

module.exports = {
up: async (queryInterface, Sequelize) => {
up: async (queryInterface) => {
await queryInterface.createTable('coBenefits', modelTypes);
},
down: async (queryInterface, Sequelize) => {
down: async (queryInterface) => {
await queryInterface.dropTable('coBenefits');
},
};
62 changes: 27 additions & 35 deletions migrations/20211212200953-fulltext-search.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,58 +5,50 @@ module.exports = {
if (queryInterface.sequelize.getDialect() === 'sqlite') {
await queryInterface.sequelize.query(`
CREATE VIRTUAL TABLE projects_fts USING fts5(
orgUid,
warehouseProjectId,
projectId,
projectLocationId,
orgUid,
currentRegistry,
projectId,
registryOfOrigin,
originProjectId,
program,
projectName,
projectLink,
projectDeveloper,
sector,
projectType,
coveredByNDC,
NDCLinkage,
projectTags,
ndcInformation,
projectStatus,
projectStatusDate,
unitMetric,
methodology,
methodologyVersion,
validationApproach,
validationDate,
projectTag,
estimatedAnnualAverageEmissionReduction
validationBody,
validationDate
);
`);
await queryInterface.sequelize.query(`
CREATE VIRTUAL TABLE units_fts USING fts5(
warehouseUnitId,
orgUid,
unitOwner,
countryJurisdictionOfOwner,
inCountryJurisdictionOfOwner,
serialNumberBlock,
serialNumberPattern,
unitIdentifier,
unitType,
intendedBuyerOrgUid,
marketplace,
tags,
unitStatus,
unitTransactionType,
unitStatusReason,
tokenIssuanceHash,
marketplaceIdentifier,
unitsIssuanceLocation,
unitRegistryLink,
unitMarketplaceLink,
correspondingAdjustmentDeclaration,
correspondingAdjustmentStatus,
issuanceId
);
warehouseUnitId,
issuanceId,
projectLocationId,
orgUid,
unitOwner,
countryJurisdictionOfOwner,
inCountryJurisdictionOfOwner,
serialNumberBlock,
serialNumberPattern,
vintageYear,
unitType,
marketplace,
marketplaceLink,
marketplaceIdentifier,
unitTags,
unitStatus,
unitStatusReason,
unitRegistryLink,
correspondingAdjustmentDeclaration,
correspondingAdjustmentStatus
);
`);
}
},
Expand Down
94 changes: 43 additions & 51 deletions migrations/20211219182106-sqlite-triggers-projects.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -6,49 +6,45 @@ module.exports = {
await queryInterface.sequelize.query(`
CREATE TRIGGER project_insert_fts AFTER INSERT ON projects BEGIN
INSERT INTO projects_fts(
warehouseProjectId,
orgUid,
warehouseProjectId,
currentRegistry,
currentRegistry,
projectId,
registryOfOrigin,
originProjectId,
program,
projectName,
projectLink,
program,
projectName,
projectLink,
projectDeveloper,
sector,
projectType,
coveredByNDC,
NDCLinkage,
sector,
projectType,
projectTags,
ndcInformation,
projectStatus,
projectStatusDate,
unitMetric,
methodology,
methodologyVersion,
validationApproach,
validationDate,
projectTag
projectStatusDate,
unitMetric,
methodology,
validationBody,
validationDate
) VALUES (
new.orgUid,
new.warehouseProjectId,
new.orgUid,
new.currentRegistry,
new.projectId,
new.registryOfOrigin,
new.originProjectId,
new.program,
new.projectName,
new.projectLink,
new.projectDeveloper,
new.sector,
new.projectType,
new.coveredByNDC,
new.NDCLinkage,
new.projectTags,
new.ndcInformation,
new.projectStatus,
new.projectStatusDate,
new.unitMetric,
new.methodology,
new.methodologyVersion,
new.validationApproach,
new.validationDate,
new.projectTag
new.validationBody,
new.validationDate
);
END;`);

Expand All @@ -62,56 +58,52 @@ module.exports = {
CREATE TRIGGER project_update_fts AFTER UPDATE ON projects BEGIN
DELETE FROM projects_fts WHERE warehouseProjectId = old.warehouseProjectId;
INSERT INTO projects_fts(
warehouseProjectId,
orgUid,
warehouseProjectId,
currentRegistry,
currentRegistry,
projectId,
registryOfOrigin,
originProjectId,
program,
projectName,
projectLink,
program,
projectName,
projectLink,
projectDeveloper,
sector,
projectType,
coveredByNDC,
NDCLinkage,
sector,
projectType,
projectTags,
ndcInformation,
projectStatus,
projectStatusDate,
unitMetric,
methodology,
methodologyVersion,
validationApproach,
validationDate,
projectTag
projectStatusDate,
unitMetric,
methodology,
validationBody,
validationDate
) VALUES (
new.orgUid,
new.warehouseProjectId,
new.orgUid,
new.currentRegistry,
new.projectId,
new.registryOfOrigin,
new.originProjectId,
new.program,
new.projectName,
new.projectLink,
new.projectDeveloper,
new.sector,
new.projectType,
new.coveredByNDC,
new.NDCLinkage,
new.projectTags,
new.ndcInformation,
new.projectStatus,
new.projectStatusDate,
new.unitMetric,
new.methodology,
new.methodologyVersion,
new.validationApproach,
new.validationDate,
new.projectTag
new.validationBody,
new.validationDate
);
END;
`);
}
},

down: async (queryInterface, Sequelize) => {
down: async (queryInterface) => {
if (queryInterface.sequelize.getDialect() === 'sqlite') {
await queryInterface.sequelize.query('DROP TRIGGER project_insert_fts;');
await queryInterface.sequelize.query('DROP TRIGGER project_delete_fts;');
Expand Down
68 changes: 28 additions & 40 deletions migrations/20211219184405-sqlite-triggers-units.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -7,52 +7,46 @@ module.exports = {
CREATE TRIGGER unit_insert_fts AFTER INSERT ON units BEGIN
INSERT INTO units_fts(
warehouseUnitId,
issuanceId,
projectLocationId,
orgUid,
unitOwner,
countryJurisdictionOfOwner,
inCountryJurisdictionOfOwner,
serialNumberBlock,
serialNumberPattern,
unitIdentifier,
vintageYear,
unitType,
intendedBuyerOrgUid,
marketplace,
tags,
marketplaceLink,
marketplaceIdentifier,
unitTags,
unitStatus,
unitTransactionType,
unitStatusReason,
tokenIssuanceHash,
marketplaceIdentifier,
unitsIssuanceLocation,
unitRegistryLink,
unitMarketplaceLink,
correspondingAdjustmentDeclaration,
correspondingAdjustmentStatus,
issuanceId
correspondingAdjustmentStatus
) VALUES (
new.warehouseUnitId,
new.issuanceId,
new.projectLocationId,
new.orgUid,
new.unitOwner,
new.countryJurisdictionOfOwner,
new.inCountryJurisdictionOfOwner,
new.serialNumberBlock,
new.serialNumberPattern,
new.unitIdentifier,
new.vintageYear,
new.unitType,
new.intendedBuyerOrgUid,
new.marketplace,
new.tags,
new.marketplaceLink,
new.marketplaceIdentifier,
new.unitTags,
new.unitStatus,
new.unitTransactionType,
new.unitStatusReason,
new.tokenIssuanceHash,
new.marketplaceIdentifier,
new.unitsIssuanceLocation,
new.unitRegistryLink,
new.unitMarketplaceLink,
new.correspondingAdjustmentDeclaration,
new.correspondingAdjustmentStatus,
new.issuanceId
new.correspondingAdjustmentStatus
);
END;`);

Expand All @@ -67,52 +61,46 @@ module.exports = {
DELETE FROM units_fts WHERE warehouseUnitId = old.warehouseUnitId;
INSERT INTO units_fts(
warehouseUnitId,
issuanceId,
projectLocationId,
orgUid,
unitOwner,
countryJurisdictionOfOwner,
inCountryJurisdictionOfOwner,
serialNumberBlock,
serialNumberPattern,
unitIdentifier,
vintageYear,
unitType,
intendedBuyerOrgUid,
marketplace,
tags,
marketplaceLink,
marketplaceIdentifier,
unitTags,
unitStatus,
unitTransactionType,
unitStatusReason,
tokenIssuanceHash,
marketplaceIdentifier,
unitsIssuanceLocation,
unitRegistryLink,
unitMarketplaceLink,
correspondingAdjustmentDeclaration,
correspondingAdjustmentStatus,
issuanceId
correspondingAdjustmentStatus
) VALUES (
new.warehouseUnitId,
new.issuanceId,
new.projectLocationId,
new.orgUid,
new.unitOwner,
new.countryJurisdictionOfOwner,
new.inCountryJurisdictionOfOwner,
new.serialNumberBlock,
new.serialNumberPattern,
new.unitIdentifier,
new.vintageYear,
new.unitType,
new.intendedBuyerOrgUid,
new.marketplace,
new.tags,
new.marketplaceLink,
new.marketplaceIdentifier,
new.unitTags,
new.unitStatus,
new.unitTransactionType,
new.unitStatusReason,
new.tokenIssuanceHash,
new.marketplaceIdentifier,
new.unitsIssuanceLocation,
new.unitRegistryLink,
new.unitMarketplaceLink,
new.correspondingAdjustmentDeclaration,
new.correspondingAdjustmentStatus,
new.issuanceId
new.correspondingAdjustmentStatus
);
END;
`);
Expand Down
Loading

0 comments on commit f309cb6

Please sign in to comment.