-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #23 from IntersectMBO/Bugfix-(change-request)-#2378
Bugfix (change request) #2378 Backend step 1
- Loading branch information
Showing
7 changed files
with
356 additions
and
1,149 deletions.
There are no files selected for viewing
37 changes: 37 additions & 0 deletions
37
backend/database/migrations/20241121_1_WithdrawalsCopyDataToTempSchema.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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!'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} | ||
} | ||
} |
Oops, something went wrong.