Skip to content

Commit

Permalink
Merge pull request #28 from IntersectMBO/pre-prod
Browse files Browse the repository at this point in the history
From Pre-prod to Main
  • Loading branch information
nebojsact authored Nov 26, 2024
2 parents 83d81c0 + 99ab315 commit 8f0af63
Show file tree
Hide file tree
Showing 15 changed files with 705 additions and 1,360 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
// This script must be run wih first start on old source database
// this is just to copy data to new schema that will not be synced with main schema
module.exports = {
async up(knex) {
try {
let trx = await knex.transaction();
let result = await trx.raw( `SELECT id, prop_receiving_address, prop_amount
FROM proposal_contents
WHERE prop_receiving_address IS NOT NULL;`);
await trx.raw('CREATE SCHEMA IF NOT EXISTS temp');
await trx.raw(`
CREATE TABLE IF NOT EXISTS temp.temp_migrate_data (
id int4 PRIMARY KEY,
prop_receiving_address VARCHAR(255),
prop_amount DECIMAL
);
`);
result = await trx.raw(`
INSERT INTO temp.temp_migrate_data (id, prop_receiving_address, prop_amount)
SELECT id, prop_receiving_address, prop_amount
FROM proposal_contents
WHERE prop_receiving_address IS NOT NULL;
`);
console.log("Data coppied to temp table temp_migrate_data");
await trx.raw('ALTER TABLE proposal_contents DROP COLUMN prop_receiving_address');
console.log("Columns prop_receiving_address dropped successfully");
await trx.raw('ALTER TABLE proposal_contents DROP COLUMN prop_amount');
console.log("Columns prop_amount dropped successfully");
trx.commit();
}
catch(error)
{
console.error('Error copping data:', error);
}
console.log('Migration 20241121_1 completed!');
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,33 +20,24 @@
"default": false
},
"prop_abstract": {
"type": "text",
"maxLength": 2500
},
"type": "text",
"maxLength": 2500
},
"prop_motivation": {
"type": "text",
"maxLength": 12000
},
"type": "text",
"maxLength": 12000
},
"prop_rationale": {
"type": "text",
"maxLength": 12000
},
"type": "text",
"maxLength": 12000
},
"gov_action_type_id": {
"type": "string"
},
"prop_name": {
"type": "string",
"required": true,
"maxLength": 80
},
"prop_receiving_address": {
"type": "string",
"required": false,
"maxLength": 200
},
"prop_amount": {
"type": "float",
"required": false
"required": true,
"maxLength": 80
},
"proposal_links": {
"type": "component",
Expand All @@ -71,6 +62,12 @@
},
"prop_submission_date": {
"type": "date"
},
"proposal_withdrawals": {
"displayName": "proposal_withdrawals",
"type": "component",
"repeatable": true,
"component": "proposal.proposal-withdrawals"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ module.exports = createCoreController(
if (!sanitizedQueryParams?.populate?.includes("proposal_links")) {
sanitizedQueryParams.populate.push("proposal_links");
}

if (!sanitizedQueryParams?.populate?.includes("proposal_withdrawals")) {
sanitizedQueryParams.populate.push("proposal_withdrawals");
}
const { results, pagination } = await strapi
.service("api::proposal-content.proposal-content")
.find(sanitizedQueryParams);
Expand Down
18 changes: 18 additions & 0 deletions backend/src/components/proposal/proposal-withdrawals.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"collectionName": "components_proposal_proposal_withdrawals",
"info": {
"displayName": "proposal_withdrawals",
"description": ""
},
"options": {},
"attributes": {
"prop_receiving_address": {
"type": "string",
"maxLength": 200
},
"prop_amount": {
"type": "float",
"min": 0
}
}
}
Loading

0 comments on commit 8f0af63

Please sign in to comment.