|
| 1 | +import { MigrationInterface, QueryRunner } from 'typeorm'; |
| 2 | + |
| 3 | +export class AddVestingTableMigration1746211907434 |
| 4 | + implements MigrationInterface |
| 5 | +{ |
| 6 | + name = 'Migration1746211907434'; |
| 7 | + |
| 8 | + public async up(queryRunner: QueryRunner): Promise<void> { |
| 9 | + await queryRunner.query( |
| 10 | + `CREATE TABLE "vesting_data" ("id" SERIAL NOT NULL, "status" text NOT NULL DEFAULT 'pending', "walletAddress" character varying, "paymentToken" character varying NOT NULL, "amount" bigint NOT NULL, "rewardStreamStart" TIMESTAMP, "cliff" double precision, "rewardStreamEnd" TIMESTAMP, "createdAt" TIMESTAMP NOT NULL DEFAULT now(), "projectId" integer, "userId" integer, CONSTRAINT "PK_c8abbf61fa05ae0eec4048b6408" PRIMARY KEY ("id"))`, |
| 11 | + ); |
| 12 | + await queryRunner.query( |
| 13 | + `CREATE INDEX "IDX_2826daca8f0317c5e209df4de5" ON "vesting_data" ("projectId") `, |
| 14 | + ); |
| 15 | + await queryRunner.query( |
| 16 | + `CREATE INDEX "IDX_b81d2052f429a1bce90dc68e2e" ON "vesting_data" ("userId") `, |
| 17 | + ); |
| 18 | + await queryRunner.query( |
| 19 | + `ALTER TABLE "vesting_data" ADD CONSTRAINT "FK_2826daca8f0317c5e209df4de55" FOREIGN KEY ("projectId") REFERENCES "project"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`, |
| 20 | + ); |
| 21 | + await queryRunner.query( |
| 22 | + `ALTER TABLE "vesting_data" ADD CONSTRAINT "FK_b81d2052f429a1bce90dc68e2ee" FOREIGN KEY ("userId") REFERENCES "user"("id") ON DELETE CASCADE ON UPDATE NO ACTION`, |
| 23 | + ); |
| 24 | + } |
| 25 | + |
| 26 | + public async down(queryRunner: QueryRunner): Promise<void> { |
| 27 | + await queryRunner.query( |
| 28 | + `ALTER TABLE "vesting_data" DROP CONSTRAINT "FK_b81d2052f429a1bce90dc68e2ee"`, |
| 29 | + ); |
| 30 | + await queryRunner.query( |
| 31 | + `ALTER TABLE "vesting_data" DROP CONSTRAINT "FK_2826daca8f0317c5e209df4de55"`, |
| 32 | + ); |
| 33 | + await queryRunner.query( |
| 34 | + `DROP INDEX "public"."IDX_b81d2052f429a1bce90dc68e2e"`, |
| 35 | + ); |
| 36 | + await queryRunner.query( |
| 37 | + `DROP INDEX "public"."IDX_2826daca8f0317c5e209df4de5"`, |
| 38 | + ); |
| 39 | + await queryRunner.query(`DROP TABLE "vesting_data"`); |
| 40 | + } |
| 41 | +} |
0 commit comments