-
Notifications
You must be signed in to change notification settings - Fork 18
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 #1190 from Giveth/hotfix_1186_add_matching_funds_a…
…s_donations Hotfix add matching funds as donations
- Loading branch information
Showing
13 changed files
with
645 additions
and
12 deletions.
There are no files selected for viewing
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,69 @@ | ||
import { MigrationInterface, QueryRunner } from 'typeorm'; | ||
|
||
export class addFieldsToQfRoundHistory1701689359018 | ||
implements MigrationInterface | ||
{ | ||
async up(queryRunner: QueryRunner): Promise<void> { | ||
await queryRunner.query(` | ||
ALTER TABLE "qf_round_history" | ||
ADD COLUMN "matchingFundAmount" real , | ||
ADD COLUMN "matchingFundPriceUsd" real , | ||
ADD COLUMN "matchingFundCurrency" text ; | ||
`); | ||
|
||
await queryRunner.query(` | ||
ALTER TABLE "donation" | ||
ADD COLUMN "distributedFundQfRoundId" integer; | ||
-- If you have a foreign key constraint to enforce the relationship | ||
ALTER TABLE "donation" | ||
ADD CONSTRAINT "FK_donation_qfRound" | ||
FOREIGN KEY ("distributedFundQfRoundId") REFERENCES "qf_round"("id"); | ||
`); | ||
|
||
// These rounds are in Production but I didnt set any condition for that | ||
// because I want this part of code be executed in staging ENV | ||
|
||
// Alpha round in production | ||
await queryRunner.query(` | ||
UPDATE qf_round_history | ||
SET | ||
"matchingFundAmount" = "matchingFund", | ||
"matchingFundPriceUsd" = 1, | ||
"matchingFundCurrency" = 'WXDAI' | ||
WHERE | ||
id = 2 AND "matchingFund" IS NOT NULL; | ||
`); | ||
|
||
// Optimism round in production | ||
await queryRunner.query(` | ||
UPDATE qf_round_history | ||
SET | ||
"matchingFundAmount" = "matchingFund", | ||
"matchingFundPriceUsd" = 1, | ||
"matchingFundCurrency" = 'DAI' | ||
WHERE | ||
id = 4 AND "matchingFund" IS NOT NULL; | ||
`); | ||
} | ||
|
||
async down(queryRunner: QueryRunner): Promise<void> { | ||
await queryRunner.query(` | ||
ALTER TABLE "qf_round_history" | ||
DROP COLUMN "matchingFundAmount", | ||
DROP COLUMN "matchingFundPriceUsd", | ||
DROP COLUMN "matchingFundCurrency"; | ||
`); | ||
|
||
await queryRunner.query(` | ||
-- If you added a foreign key constraint, remove it first | ||
ALTER TABLE "donation" | ||
DROP CONSTRAINT IF EXISTS "FK_donation_qfRound"; | ||
ALTER TABLE "donation" | ||
DROP COLUMN "distributedFundQfRoundId"; | ||
`); | ||
} | ||
} |
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,25 @@ | ||
import { MigrationInterface, QueryRunner } from 'typeorm'; | ||
const donationDotEthAddress = '0x6e8873085530406995170Da467010565968C7C62'; // Address behind donation.eth ENS address; | ||
const matchingFundDonationsFromAddress = | ||
(process.env.MATCHING_FUND_DONATIONS_FROM_ADDRESS as string) || | ||
donationDotEthAddress; | ||
|
||
export class createDonationethUser1701756190381 implements MigrationInterface { | ||
async up(queryRunner: QueryRunner): Promise<void> { | ||
await queryRunner.query(` | ||
INSERT INTO public."user" ("walletAddress", "name", "loginType", "role") | ||
VALUES ('${matchingFundDonationsFromAddress}', 'Donation.eth', 'wallet', 'restricted') | ||
ON CONFLICT ("walletAddress") DO NOTHING | ||
`); | ||
} | ||
|
||
async down(queryRunner: QueryRunner): Promise<void> { | ||
if (!matchingFundDonationsFromAddress) { | ||
throw new Error('Wallet address is not defined in the configuration.'); | ||
} | ||
|
||
await queryRunner.query( | ||
`DELETE FROM public."user" WHERE "walletAddress" = '${matchingFundDonationsFromAddress}'`, | ||
); | ||
} | ||
} |
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
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
Oops, something went wrong.