Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugfix (change request) #2378 Backend step 1 #23

Merged
merged 1 commit into from
Nov 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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