|
| 1 | +import { MigrationInterface, QueryRunner } from 'typeorm'; |
| 2 | + |
| 3 | +export class PaymentIntent1725449786396 implements MigrationInterface { |
| 4 | + name = 'PaymentIntent1725449786396'; |
| 5 | + |
| 6 | + public async up(queryRunner: QueryRunner): Promise<void> { |
| 7 | + await queryRunner.query(` |
| 8 | + CREATE TABLE "hmt"."payments-info" ( |
| 9 | + "id" SERIAL NOT NULL, |
| 10 | + "created_at" TIMESTAMP WITH TIME ZONE NOT NULL, |
| 11 | + "updated_at" TIMESTAMP WITH TIME ZONE NOT NULL, |
| 12 | + "customer_id" character varying NOT NULL, |
| 13 | + "payment_method_id" character varying NOT NULL, |
| 14 | + "user_id" integer NOT NULL, |
| 15 | + CONSTRAINT "PK_b4970c6db0e80ea900a06ebc171" PRIMARY KEY ("id") |
| 16 | + ) |
| 17 | + `); |
| 18 | + await queryRunner.query(` |
| 19 | + CREATE UNIQUE INDEX "IDX_35c9ce414705e7b718a58aa6f0" ON "hmt"."payments-info" ("customer_id") |
| 20 | + `); |
| 21 | + await queryRunner.query(` |
| 22 | + CREATE UNIQUE INDEX "IDX_63719fa3540ac47f61cc4a7ba1" ON "hmt"."payments-info" ("user_id") |
| 23 | + `); |
| 24 | + await queryRunner.query(` |
| 25 | + ALTER TYPE "hmt"."payments_type_enum" |
| 26 | + RENAME TO "payments_type_enum_old" |
| 27 | + `); |
| 28 | + await queryRunner.query(` |
| 29 | + CREATE TYPE "hmt"."payments_type_enum" AS ENUM('DEPOSIT', 'REFUND', 'WITHDRAWAL', 'SLASH') |
| 30 | + `); |
| 31 | + await queryRunner.query(` |
| 32 | + ALTER TABLE "hmt"."payments" |
| 33 | + ALTER COLUMN "type" TYPE "hmt"."payments_type_enum" USING "type"::"text"::"hmt"."payments_type_enum" |
| 34 | + `); |
| 35 | + await queryRunner.query(` |
| 36 | + DROP TYPE "hmt"."payments_type_enum_old" |
| 37 | + `); |
| 38 | + await queryRunner.query(` |
| 39 | + DROP INDEX "hmt"."IDX_012a8481fc9980fcc49f3f0dc2" |
| 40 | + `); |
| 41 | + await queryRunner.query(` |
| 42 | + ALTER TYPE "hmt"."webhook_event_type_enum" |
| 43 | + RENAME TO "webhook_event_type_enum_old" |
| 44 | + `); |
| 45 | + await queryRunner.query(` |
| 46 | + CREATE TYPE "hmt"."webhook_event_type_enum" AS ENUM( |
| 47 | + 'escrow_created', |
| 48 | + 'escrow_canceled', |
| 49 | + 'escrow_completed', |
| 50 | + 'task_creation_failed', |
| 51 | + 'escrow_failed', |
| 52 | + 'abuse' |
| 53 | + ) |
| 54 | + `); |
| 55 | + await queryRunner.query(` |
| 56 | + ALTER TABLE "hmt"."webhook" |
| 57 | + ALTER COLUMN "event_type" TYPE "hmt"."webhook_event_type_enum" USING "event_type"::"text"::"hmt"."webhook_event_type_enum" |
| 58 | + `); |
| 59 | + await queryRunner.query(` |
| 60 | + DROP TYPE "hmt"."webhook_event_type_enum_old" |
| 61 | + `); |
| 62 | + await queryRunner.query(` |
| 63 | + ALTER TYPE "hmt"."cron-jobs_cron_job_type_enum" |
| 64 | + RENAME TO "cron-jobs_cron_job_type_enum_old" |
| 65 | + `); |
| 66 | + await queryRunner.query(` |
| 67 | + CREATE TYPE "hmt"."cron-jobs_cron_job_type_enum" AS ENUM( |
| 68 | + 'create-escrow', |
| 69 | + 'setup-escrow', |
| 70 | + 'fund-escrow', |
| 71 | + 'cancel-escrow', |
| 72 | + 'process-pending-webhook', |
| 73 | + 'sync-job-statuses', |
| 74 | + 'abuse' |
| 75 | + ) |
| 76 | + `); |
| 77 | + await queryRunner.query(` |
| 78 | + ALTER TABLE "hmt"."cron-jobs" |
| 79 | + ALTER COLUMN "cron_job_type" TYPE "hmt"."cron-jobs_cron_job_type_enum" USING "cron_job_type"::"text"::"hmt"."cron-jobs_cron_job_type_enum" |
| 80 | + `); |
| 81 | + await queryRunner.query(` |
| 82 | + DROP TYPE "hmt"."cron-jobs_cron_job_type_enum_old" |
| 83 | + `); |
| 84 | + await queryRunner.query(` |
| 85 | + CREATE UNIQUE INDEX "IDX_012a8481fc9980fcc49f3f0dc2" ON "hmt"."webhook" ("chain_id", "escrow_address", "event_type") |
| 86 | + `); |
| 87 | + await queryRunner.query(` |
| 88 | + ALTER TABLE "hmt"."payments-info" |
| 89 | + ADD CONSTRAINT "FK_63719fa3540ac47f61cc4a7ba11" FOREIGN KEY ("user_id") REFERENCES "hmt"."users"("id") ON DELETE NO ACTION ON UPDATE NO ACTION |
| 90 | + `); |
| 91 | + } |
| 92 | + |
| 93 | + public async down(queryRunner: QueryRunner): Promise<void> { |
| 94 | + await queryRunner.query(` |
| 95 | + ALTER TABLE "hmt"."payments-info" DROP CONSTRAINT "FK_63719fa3540ac47f61cc4a7ba11" |
| 96 | + `); |
| 97 | + await queryRunner.query(` |
| 98 | + DROP INDEX "hmt"."IDX_012a8481fc9980fcc49f3f0dc2" |
| 99 | + `); |
| 100 | + await queryRunner.query(` |
| 101 | + CREATE TYPE "hmt"."cron-jobs_cron_job_type_enum_old" AS ENUM( |
| 102 | + 'create-escrow', |
| 103 | + 'setup-escrow', |
| 104 | + 'fund-escrow', |
| 105 | + 'cancel-escrow', |
| 106 | + 'process-pending-webhook', |
| 107 | + 'sync-job-statuses' |
| 108 | + ) |
| 109 | + `); |
| 110 | + await queryRunner.query(` |
| 111 | + ALTER TABLE "hmt"."cron-jobs" |
| 112 | + ALTER COLUMN "cron_job_type" TYPE "hmt"."cron-jobs_cron_job_type_enum_old" USING "cron_job_type"::"text"::"hmt"."cron-jobs_cron_job_type_enum_old" |
| 113 | + `); |
| 114 | + await queryRunner.query(` |
| 115 | + DROP TYPE "hmt"."cron-jobs_cron_job_type_enum" |
| 116 | + `); |
| 117 | + await queryRunner.query(` |
| 118 | + ALTER TYPE "hmt"."cron-jobs_cron_job_type_enum_old" |
| 119 | + RENAME TO "cron-jobs_cron_job_type_enum" |
| 120 | + `); |
| 121 | + await queryRunner.query(` |
| 122 | + CREATE TYPE "hmt"."webhook_event_type_enum_old" AS ENUM( |
| 123 | + 'escrow_created', |
| 124 | + 'escrow_canceled', |
| 125 | + 'escrow_completed', |
| 126 | + 'task_creation_failed', |
| 127 | + 'escrow_failed' |
| 128 | + ) |
| 129 | + `); |
| 130 | + await queryRunner.query(` |
| 131 | + ALTER TABLE "hmt"."webhook" |
| 132 | + ALTER COLUMN "event_type" TYPE "hmt"."webhook_event_type_enum_old" USING "event_type"::"text"::"hmt"."webhook_event_type_enum_old" |
| 133 | + `); |
| 134 | + await queryRunner.query(` |
| 135 | + DROP TYPE "hmt"."webhook_event_type_enum" |
| 136 | + `); |
| 137 | + await queryRunner.query(` |
| 138 | + ALTER TYPE "hmt"."webhook_event_type_enum_old" |
| 139 | + RENAME TO "webhook_event_type_enum" |
| 140 | + `); |
| 141 | + await queryRunner.query(` |
| 142 | + CREATE UNIQUE INDEX "IDX_012a8481fc9980fcc49f3f0dc2" ON "hmt"."webhook" ("chain_id", "escrow_address", "event_type") |
| 143 | + `); |
| 144 | + await queryRunner.query(` |
| 145 | + CREATE TYPE "hmt"."payments_type_enum_old" AS ENUM('DEPOSIT', 'REFUND', 'WITHDRAWAL') |
| 146 | + `); |
| 147 | + await queryRunner.query(` |
| 148 | + ALTER TABLE "hmt"."payments" |
| 149 | + ALTER COLUMN "type" TYPE "hmt"."payments_type_enum_old" USING "type"::"text"::"hmt"."payments_type_enum_old" |
| 150 | + `); |
| 151 | + await queryRunner.query(` |
| 152 | + DROP TYPE "hmt"."payments_type_enum" |
| 153 | + `); |
| 154 | + await queryRunner.query(` |
| 155 | + ALTER TYPE "hmt"."payments_type_enum_old" |
| 156 | + RENAME TO "payments_type_enum" |
| 157 | + `); |
| 158 | + await queryRunner.query(` |
| 159 | + DROP INDEX "hmt"."IDX_63719fa3540ac47f61cc4a7ba1" |
| 160 | + `); |
| 161 | + await queryRunner.query(` |
| 162 | + DROP INDEX "hmt"."IDX_35c9ce414705e7b718a58aa6f0" |
| 163 | + `); |
| 164 | + await queryRunner.query(` |
| 165 | + DROP TABLE "hmt"."payments-info" |
| 166 | + `); |
| 167 | + } |
| 168 | +} |
0 commit comments