-
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 #1783 from Giveth/staging
Next Release Aug 2024
- Loading branch information
Showing
52 changed files
with
2,498 additions
and
123 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,17 @@ | ||
import { MigrationInterface, QueryRunner } from 'typeorm'; | ||
|
||
export class AddMemoToProjectAddressFields1722379846122 | ||
implements MigrationInterface | ||
{ | ||
public async up(queryRunner: QueryRunner): Promise<void> { | ||
await queryRunner.query( | ||
`ALTER TABLE "project_address" ADD COLUMN IF NOT EXISTS "memo" VARCHAR`, | ||
); | ||
} | ||
|
||
public async down(queryRunner: QueryRunner): Promise<void> { | ||
await queryRunner.query( | ||
`ALTER TABLE "project_address" DROP COLUMN IF EXISTS "memo"`, | ||
); | ||
} | ||
} |
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'; | ||
import { Token } from '../src/entities/token'; | ||
import seedTokens from './data/seedTokens'; | ||
import { NETWORK_IDS } from '../src/provider'; | ||
|
||
export class AddStellarTokens1722475689162 implements MigrationInterface { | ||
public async up(queryRunner: QueryRunner): Promise<void> { | ||
const networkId = NETWORK_IDS.STELLAR_MAINNET; | ||
|
||
//add isQR code to token | ||
await queryRunner.query( | ||
`ALTER TABLE token ADD COLUMN IF NOT EXISTS "isQR" BOOLEAN DEFAULT FALSE NOT NULL`, | ||
); | ||
|
||
await queryRunner.manager.save( | ||
Token, | ||
seedTokens | ||
.filter(token => token.networkId === networkId) | ||
.map(token => { | ||
const t = { | ||
...token, | ||
}; | ||
t.address = t.address?.toUpperCase(); | ||
return t; | ||
}), | ||
); | ||
const tokens = await queryRunner.query(` | ||
SELECT * FROM token | ||
WHERE "networkId" = ${networkId} | ||
`); | ||
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) { | ||
// Add all Stellar tokens to Giveth organization | ||
await queryRunner.query(`INSERT INTO organization_tokens_token ("tokenId","organizationId") VALUES | ||
(${token.id}, ${givethOrganization.id}), | ||
(${token.id}, ${traceOrganization.id}) | ||
;`); | ||
} | ||
} | ||
|
||
public async down(queryRunner: QueryRunner): Promise<void> { | ||
const networkId = NETWORK_IDS.STELLAR_MAINNET; | ||
|
||
await queryRunner.query(`ALTER TABLE token DROP COLUMN IF EXISTS "isQR"`); | ||
|
||
const tokens = await queryRunner.query(` | ||
SELECT * FROM token | ||
WHERE "networkId" = ${networkId} | ||
`); | ||
|
||
for (const token of tokens) { | ||
await queryRunner.query( | ||
`DELETE FROM organization_tokens_token WHERE "tokenId" = ${token.id}`, | ||
); | ||
} | ||
await queryRunner.query( | ||
`DELETE FROM token WHERE "networkId" = ${networkId}`, | ||
); | ||
} | ||
} |
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'; | ||
|
||
export class AddDraftDonationQRFields1722800845343 | ||
implements MigrationInterface | ||
{ | ||
public async up(queryRunner: QueryRunner): Promise<void> { | ||
await queryRunner.query(` | ||
ALTER TABLE draft_donation | ||
ADD COLUMN IF NOT EXISTS "toWalletMemo" VARCHAR NULL, | ||
ADD COLUMN IF NOT EXISTS "qrCodeDataUrl" TEXT NULL, | ||
ADD COLUMN IF NOT EXISTS "isQRDonation" BOOLEAN DEFAULT FALSE; | ||
`); | ||
|
||
// update enum draft_donation_chaintype_enum (add 'STELLAR'); | ||
await queryRunner.query( | ||
`ALTER TYPE public.draft_donation_chaintype_enum ADD VALUE IF NOT EXISTS 'STELLAR';`, | ||
); | ||
} | ||
|
||
public async down(queryRunner: QueryRunner): Promise<void> { | ||
await queryRunner.query(` | ||
ALTER TABLE draft_donation | ||
DROP COLUMN IF EXISTS "toWalletMemo", | ||
DROP COLUMN IF EXISTS "qrCodeDataUrl", | ||
DROP COLUMN IF EXISTS "isQRDonation"; | ||
`); | ||
|
||
// update enum draft_donation_chaintype_enum (remove 'STELLAR'); | ||
await queryRunner.query(` | ||
DELETE FROM pg_enum | ||
WHERE enumlabel = 'STELLAR' | ||
AND enumtypid = ( | ||
SELECT oid | ||
FROM pg_type | ||
WHERE typname = 'draft_donation_chaintype_enum' | ||
); | ||
`); | ||
} | ||
} |
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,35 @@ | ||
import { MigrationInterface, QueryRunner } from 'typeorm'; | ||
|
||
export class UpdateDraftDonationIndex1722860378721 | ||
implements MigrationInterface | ||
{ | ||
public async up(queryRunner: QueryRunner): Promise<void> { | ||
await queryRunner.query(`DROP INDEX "IDX_af180374473ea402e7595196a6"`); | ||
await queryRunner.query(` | ||
CREATE UNIQUE INDEX IF NOT EXISTS "IDX_af180374473ea402e7595196a6" | ||
ON public.draft_donation USING btree | ||
("fromWalletAddress" COLLATE pg_catalog."default" ASC NULLS LAST, | ||
"toWalletAddress" COLLATE pg_catalog."default" ASC NULLS LAST, | ||
"networkId" ASC NULLS LAST, | ||
amount ASC NULLS LAST, | ||
currency COLLATE pg_catalog."default" ASC NULLS LAST) | ||
TABLESPACE pg_default | ||
WHERE status = 'pending'::draft_donation_status_enum AND "isQRDonation" = false; | ||
`); | ||
} | ||
|
||
public async down(queryRunner: QueryRunner): Promise<void> { | ||
await queryRunner.query(`DROP INDEX "IDX_af180374473ea402e7595196a6"`); | ||
await queryRunner.query(` | ||
CREATE UNIQUE INDEX IF NOT EXISTS "IDX_af180374473ea402e7595196a6" | ||
ON public.draft_donation USING btree | ||
("fromWalletAddress" COLLATE pg_catalog."default" ASC NULLS LAST, | ||
"toWalletAddress" COLLATE pg_catalog."default" ASC NULLS LAST, | ||
"networkId" ASC NULLS LAST, | ||
amount ASC NULLS LAST, | ||
currency COLLATE pg_catalog."default" ASC NULLS LAST) | ||
TABLESPACE pg_default | ||
WHERE status = 'pending'::draft_donation_status_enum; | ||
`); | ||
} | ||
} |
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,30 @@ | ||
import { MigrationInterface, QueryRunner } from 'typeorm'; | ||
|
||
export class UpdateDonationIndex1722963339892 implements MigrationInterface { | ||
public async up(queryRunner: QueryRunner): Promise<void> { | ||
// update donation table | ||
await queryRunner.query(` | ||
ALTER TABLE "donation" | ||
ADD COLUMN IF NOT EXISTS "isQRDonation" boolean DEFAULT false, | ||
ADD COLUMN IF NOT EXISTS "toWalletMemo" text; | ||
`); | ||
|
||
await queryRunner.query(`DROP INDEX "idx_donation_project_user"`); | ||
await queryRunner.query( | ||
`CREATE INDEX IF NOT EXISTS idx_donation_project_user ON donation("projectId", "userId", "valueUsd") WHERE "status" = 'verified' AND "recurringDonationId" IS NULL AND "isQRDonation" = false AND "userId" IS NOT NULL`, | ||
); | ||
} | ||
|
||
public async down(queryRunner: QueryRunner): Promise<void> { | ||
await queryRunner.query(`DROP INDEX "idx_donation_project_user"`); | ||
await queryRunner.query( | ||
`CREATE INDEX IF NOT EXISTS idx_donation_project_user ON donation("projectId", "userId", "valueUsd") WHERE "status" = 'verified' AND "recurringDonationId" IS NULL`, | ||
); | ||
|
||
await queryRunner.query(` | ||
ALTER TABLE "donation" | ||
DROP COLUMN IF EXISTS "isQRDonation", | ||
DROP COLUMN IF EXISTS "toWalletMemo"; | ||
`); | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
migration/1723025859680-AddExpirationDateToDraftDonation.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,17 @@ | ||
import { MigrationInterface, QueryRunner } from 'typeorm'; | ||
|
||
export class AddExpirationDateToDraftDonation1723025859680 | ||
implements MigrationInterface | ||
{ | ||
public async up(queryRunner: QueryRunner): Promise<void> { | ||
await queryRunner.query( | ||
`ALTER TABLE draft_donation ADD COLUMN IF NOT EXISTS "expiresAt" TIMESTAMP`, | ||
); | ||
} | ||
|
||
public async down(queryRunner: QueryRunner): Promise<void> { | ||
await queryRunner.query( | ||
`ALTER TABLE draft_donation DROP COLUMN IF EXISTS "expiresAt"`, | ||
); | ||
} | ||
} |
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,65 @@ | ||
import { MigrationInterface, QueryRunner } from 'typeorm'; | ||
import { Token } from '../src/entities/token'; | ||
import { NETWORK_IDS } from '../src/provider'; | ||
import seedTokens from './data/seedTokens'; | ||
import config from '../src/config'; | ||
|
||
export class AddSepoliaToken1724166731604 implements MigrationInterface { | ||
async up(queryRunner: QueryRunner): Promise<void> { | ||
const environment = config.get('ENVIRONMENT') as string; | ||
// We don't add sepolia tokens in production ENV | ||
if (environment === 'production') return; | ||
|
||
await queryRunner.manager.save( | ||
Token, | ||
seedTokens | ||
.filter(token => token.networkId === NETWORK_IDS.SEPOLIA) | ||
.map(token => { | ||
const t = { | ||
...token, | ||
}; | ||
t.address = t.address?.toLowerCase(); | ||
delete t.chainType; | ||
return t; | ||
}), | ||
); | ||
|
||
const tokens = await queryRunner.query(` | ||
SELECT * FROM token | ||
WHERE "networkId" = ${NETWORK_IDS.SEPOLIA} | ||
`); | ||
|
||
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 environment = config.get('ENVIRONMENT') as string; | ||
// We don't add sepolia tokens in production ENV | ||
if (environment === 'production') return; | ||
await queryRunner.query(` | ||
DELETE FROM organization_tokens_token | ||
WHERE "tokenId" IN ( | ||
SELECT id FROM token WHERE "networkId" = ${NETWORK_IDS.SEPOLIA} | ||
); | ||
`); | ||
|
||
await queryRunner.query(` | ||
DELETE FROM token WHERE "networkId" = ${NETWORK_IDS.SEPOLIA}; | ||
`); | ||
} | ||
} |
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,35 @@ | ||
import { MigrationInterface, QueryRunner } from 'typeorm'; | ||
|
||
export class ChangeProjectAddressToSepolia1724168597216 | ||
implements MigrationInterface | ||
{ | ||
async up(queryRunner: QueryRunner): Promise<void> { | ||
const projectAddressTableExists = | ||
await queryRunner.hasTable('project_address'); | ||
if (!projectAddressTableExists) { | ||
// eslint-disable-next-line no-console | ||
console.log('The project_address table doesn’t exist'); | ||
return; | ||
} | ||
await queryRunner.query(` | ||
UPDATE project_address | ||
SET "networkId" = 11155111 | ||
WHERE "networkId" = 5 | ||
`); | ||
} | ||
|
||
async down(queryRunner: QueryRunner): Promise<void> { | ||
const projectAddressTableExists = | ||
await queryRunner.hasTable('project_address'); | ||
if (!projectAddressTableExists) { | ||
// eslint-disable-next-line no-console | ||
console.log('The project_address table doesn’t exist'); | ||
return; | ||
} | ||
await queryRunner.query(` | ||
UPDATE project_address | ||
SET "networkId" = 5 | ||
WHERE "networkId" = 11155111 | ||
`); | ||
} | ||
} |
Oops, something went wrong.