-
Notifications
You must be signed in to change notification settings - Fork 19
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 #1124 from Giveth/feature_add_network_elegibility_…
…to_qf Feature: Add eligible donations to qfround entity
- Loading branch information
Showing
6 changed files
with
181 additions
and
2 deletions.
There are no files selected for viewing
16 changes: 16 additions & 0 deletions
16
migration/1694295208252-AddEligibleNetworksToQfRoundEntity.ts
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,16 @@ | ||
import { MigrationInterface, QueryRunner, TableColumn } from 'typeorm'; | ||
|
||
export class AddEligibleNetworksToQfRoundEntity1694295208252 | ||
implements MigrationInterface | ||
{ | ||
public async up(queryRunner: QueryRunner): Promise<void> { | ||
await queryRunner.query(` | ||
ALTER TABLE "qf_round" | ||
ADD COLUMN IF NOT EXIST "eligibleNetworks" integer array DEFAULT ARRAY[]::integer[] | ||
`); | ||
} | ||
|
||
public async down(queryRunner: QueryRunner): Promise<void> { | ||
await queryRunner.dropColumn('qf_round', 'eligibleNetworks'); | ||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
migration/1694635872128-AddEligibleNetworksToPreviousQfRounds.ts
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,32 @@ | ||
import { MigrationInterface, QueryRunner } from 'typeorm'; | ||
import config from '../src/config'; | ||
|
||
export class AddEligibleNetworksToPreviousQfRounds1694635872128 | ||
implements MigrationInterface | ||
{ | ||
public async up(queryRunner: QueryRunner): Promise<void> { | ||
const environment = config.get('ENVIRONMENT') as string; | ||
|
||
// Define the eligible network IDs based on the conditions | ||
const eligibleNetworks = | ||
environment !== 'production' | ||
? [1, 3, 5, 100, 137, 10, 420, 56, 42220, 44787] // Include testnets for staging | ||
: [1, 137, 56, 42220, 100, 10]; // Exclude testnets for non-staging | ||
|
||
// Convert the eligibleNetworks array to a comma-separated string | ||
const eligibleNetworksString = eligibleNetworks.join(', '); | ||
|
||
// Update the "qf_round" table with the new eligibleNetworks values | ||
await queryRunner.query(` | ||
UPDATE "qf_round" | ||
SET eligibleNetworks = '{${eligibleNetworksString}}' | ||
`); | ||
} | ||
|
||
public async down(queryRunner: QueryRunner): Promise<void> { | ||
await queryRunner.query(` | ||
UPDATE "qf_round" | ||
SET eligibleNetworks = '{}' | ||
`); | ||
} | ||
} |
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