-
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 branch 'staging' into feat/addFillSnapshotRoundBack
- Loading branch information
Showing
97 changed files
with
10,665 additions
and
932 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
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
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 public.qf_round | ||
ADD COLUMN IF NOT EXISTS "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 | ||
|
||
// Update the "qf_round" table with the new eligibleNetworks values | ||
await queryRunner.query( | ||
` | ||
UPDATE public.qf_round | ||
SET "eligibleNetworks" = $1 | ||
`, | ||
[eligibleNetworks], | ||
); | ||
} | ||
|
||
public async down(queryRunner: QueryRunner): Promise<void> { | ||
await queryRunner.query(` | ||
UPDATE public.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import { MigrationInterface, QueryRunner, TableColumn } from 'typeorm'; | ||
|
||
export class AddExternalDonationsFields1696421249293 | ||
implements MigrationInterface | ||
{ | ||
public async up(queryRunner: QueryRunner): Promise<void> { | ||
const table = await queryRunner.getTable('donation'); | ||
if (!table?.findColumnByName('isExternal')) { | ||
await queryRunner.addColumn( | ||
'donation', | ||
new TableColumn({ | ||
name: 'isExternal', | ||
type: 'boolean', | ||
default: false, | ||
}), | ||
); | ||
} | ||
|
||
if (!table?.findColumnByName('blockNumber')) { | ||
await queryRunner.addColumn( | ||
'donation', | ||
new TableColumn({ | ||
name: 'blockNumber', | ||
type: 'integer', | ||
isNullable: true, | ||
}), | ||
); | ||
} | ||
|
||
if (!table?.findColumnByName('origin')) { | ||
await queryRunner.addColumn( | ||
'donation', | ||
new TableColumn({ | ||
name: 'origin', | ||
type: 'varchar', | ||
isNullable: true, | ||
}), | ||
); | ||
} | ||
} | ||
|
||
public async down(queryRunner: QueryRunner): Promise<void> { | ||
await queryRunner.dropColumn('donation', 'isExternal'); | ||
await queryRunner.dropColumn('donation', 'blockNumber'); | ||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
migration/1696421249293-add_isStableCoin_field_to_token_table.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,36 @@ | ||
import { MigrationInterface, QueryRunner } from 'typeorm'; | ||
|
||
export class addIsStableCoinFieldToTokenTable1696421249293 | ||
implements MigrationInterface | ||
{ | ||
public async up(queryRunner: QueryRunner): Promise<void> { | ||
// Add the isStableCoin column with a default value of false | ||
await queryRunner.query(` | ||
DO $$ | ||
BEGIN | ||
BEGIN | ||
ALTER TABLE token ADD COLUMN "isStableCoin" boolean NOT NULL DEFAULT false; | ||
EXCEPTION | ||
WHEN duplicate_column THEN | ||
-- Handle the error, or just do nothing to skip adding the column. | ||
RAISE NOTICE 'Column "isStableCoin" already exists in "token".'; | ||
END; | ||
END $$; | ||
`); | ||
|
||
// Update records to set "isStableCoin" to true based on symbol | ||
await queryRunner.query(` | ||
UPDATE token | ||
SET "isStableCoin" = true | ||
WHERE symbol IN ('USDC', 'USDT', 'DAI', 'GLO', 'pyUSD', 'XDAI', 'WXDAI', 'cUSD'); | ||
`); | ||
} | ||
|
||
public async down(queryRunner: QueryRunner): Promise<void> { | ||
// Remove the "isStableCoin" column | ||
await queryRunner.query(` | ||
ALTER TABLE token | ||
DROP COLUMN "isStableCoin"; | ||
`); | ||
} | ||
} |
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,55 @@ | ||
import { MigrationInterface, QueryRunner } from 'typeorm'; | ||
import { Token } from '../src/entities/token'; | ||
import seedTokens from './data/seedTokens'; | ||
import { NETWORK_IDS } from '../src/provider'; | ||
|
||
export class AddETCTokens1696421249294 implements MigrationInterface { | ||
async up(queryRunner: QueryRunner): Promise<void> { | ||
await queryRunner.manager.save( | ||
Token, | ||
seedTokens | ||
.filter(token => token.networkId === NETWORK_IDS.ETC) | ||
.map(t => { | ||
t.address = t.address?.toLowerCase(); | ||
return t; | ||
}), | ||
); | ||
const tokens = await queryRunner.query(` | ||
SELECT * FROM token | ||
WHERE "networkId" = ${NETWORK_IDS.ETC} | ||
`); | ||
const givethOrganization = ( | ||
await queryRunner.query(`SELECT * FROM organization | ||
WHERE label='giveth'`) | ||
)[0]; | ||
const traceOrganization = ( | ||
await queryRunner.query(`SELECT * FROM organization | ||
WHERE label='trace'`) | ||
)[0]; | ||
|
||
for (const token of tokens) { | ||
await queryRunner.query(`INSERT INTO organization_tokens_token ("tokenId","organizationId") VALUES | ||
(${token.id}, ${givethOrganization.id}), | ||
(${token.id}, ${traceOrganization.id}) | ||
;`); | ||
} | ||
} | ||
|
||
async down(queryRunner: QueryRunner): Promise<void> { | ||
const tokens = await queryRunner.query(` | ||
SELECT * FROM token | ||
WHERE "networkId" = ${NETWORK_IDS.ETC} | ||
`); | ||
await queryRunner.query( | ||
`DELETE FROM organization_tokens_token WHERE "tokenId" IN (${tokens | ||
.map(token => token.id) | ||
.join(',')})`, | ||
); | ||
await queryRunner.query( | ||
` | ||
DELETE from token | ||
WHERE "networkId" = ${NETWORK_IDS.ETC} | ||
`, | ||
); | ||
} | ||
} |
39 changes: 39 additions & 0 deletions
39
migration/1696421249294-Add_cryptoCompareId_and_coingeckoId_to_token_table.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,39 @@ | ||
import { MigrationInterface, QueryRunner } from 'typeorm'; | ||
import { Token } from '../src/entities/token'; | ||
import seedTokens from './data/seedTokens'; | ||
import { NETWORK_IDS } from '../src/provider'; | ||
|
||
export class AddCryptoCompareIdAndCoingeckoIdToTokenTable1696421249294 | ||
implements MigrationInterface | ||
{ | ||
async up(queryRunner: QueryRunner): Promise<void> { | ||
// Add the cryptoCompareId and coingeckoId columns with a default value of NULL | ||
await queryRunner.query(` | ||
DO $$ | ||
BEGIN | ||
BEGIN | ||
ALTER TABLE token ADD COLUMN "cryptoCompareId" text DEFAULT NULL; | ||
ALTER TABLE token ADD COLUMN "coingeckoId" text DEFAULT NULL; | ||
EXCEPTION | ||
WHEN duplicate_column THEN | ||
-- Handle the error, or just do nothing to skip adding the column. | ||
RAISE NOTICE 'Column "cryptoCompareId" or "coingeckoId already exists in "token".'; | ||
END; | ||
END $$; | ||
`); | ||
} | ||
|
||
async down(queryRunner: QueryRunner): Promise<void> { | ||
// Remove the "cryptoCompareId" column | ||
await queryRunner.query(` | ||
ALTER TABLE token | ||
DROP COLUMN "cryptoCompareId"; | ||
`); | ||
|
||
// Remove the "coingeckoId" column | ||
await queryRunner.query(` | ||
ALTER TABLE token | ||
DROP COLUMN "cryptoCompareId"; | ||
`); | ||
} | ||
} |
Oops, something went wrong.