From ca4498f61125b5bad716a6cfff166fdeb47d215b Mon Sep 17 00:00:00 2001 From: amateima Date: Mon, 13 Jan 2025 15:16:01 +0200 Subject: [PATCH] Fix migrations --- .../src/entities/HistoricPrice.ts | 2 +- .../migrations/1734616435674-HistoricPrice.ts | 14 ++++- .../migrations/1735922359359-RelayHashInfo.ts | 14 ++++- .../migrations/1735924259108-RelayHashInfo.ts | 23 -------- .../migrations/1736274243965-RelayHashInfo.ts | 55 ------------------- 5 files changed, 25 insertions(+), 83 deletions(-) delete mode 100644 packages/indexer-database/src/migrations/1735924259108-RelayHashInfo.ts delete mode 100644 packages/indexer-database/src/migrations/1736274243965-RelayHashInfo.ts diff --git a/packages/indexer-database/src/entities/HistoricPrice.ts b/packages/indexer-database/src/entities/HistoricPrice.ts index 0f3c4dc..22c00a8 100644 --- a/packages/indexer-database/src/entities/HistoricPrice.ts +++ b/packages/indexer-database/src/entities/HistoricPrice.ts @@ -7,7 +7,7 @@ import { } from "typeorm"; @Entity() -@Unique("UK_historic_price_baseCurrency_quoteCurrency_date", [ +@Unique("UK_hp_baseCurrency_quoteCurrency_date", [ "baseCurrency", "quoteCurrency", "date", diff --git a/packages/indexer-database/src/migrations/1734616435674-HistoricPrice.ts b/packages/indexer-database/src/migrations/1734616435674-HistoricPrice.ts index 1144242..24d6f53 100644 --- a/packages/indexer-database/src/migrations/1734616435674-HistoricPrice.ts +++ b/packages/indexer-database/src/migrations/1734616435674-HistoricPrice.ts @@ -4,9 +4,17 @@ export class HistoricPrice1734616435674 implements MigrationInterface { name = "HistoricPrice1734616435674"; public async up(queryRunner: QueryRunner): Promise { - await queryRunner.query( - `CREATE TABLE "historic_price" ("id" SERIAL NOT NULL, "baseCurrency" character varying NOT NULL, "quoteCurrency" character varying NOT NULL DEFAULT 'usd', "date" date NOT NULL, "price" numeric NOT NULL, "createdAt" TIMESTAMP NOT NULL DEFAULT now(), CONSTRAINT "UK_historic_price_baseCurrency_quoteCurrency_date" UNIQUE ("baseCurrency", "quoteCurrency", "date"), CONSTRAINT "PK_77dc3f4978cdfb03f1bb3a7444b" PRIMARY KEY ("id"))`, - ); + await queryRunner.query(` + CREATE TABLE "historic_price" ( + "id" SERIAL NOT NULL, + "baseCurrency" character varying NOT NULL, + "quoteCurrency" character varying NOT NULL DEFAULT 'usd', + "date" date NOT NULL, + "price" double precision NOT NULL, + "createdAt" TIMESTAMP NOT NULL DEFAULT now(), + CONSTRAINT "UK_hp_baseCurrency_quoteCurrency_date" UNIQUE ("baseCurrency", "quoteCurrency", "date"), + CONSTRAINT "PK_77dc3f4978cdfb03f1bb3a7444b" PRIMARY KEY ("id")) + `); } public async down(queryRunner: QueryRunner): Promise { diff --git a/packages/indexer-database/src/migrations/1735922359359-RelayHashInfo.ts b/packages/indexer-database/src/migrations/1735922359359-RelayHashInfo.ts index 3b79b32..a1514ed 100644 --- a/packages/indexer-database/src/migrations/1735922359359-RelayHashInfo.ts +++ b/packages/indexer-database/src/migrations/1735922359359-RelayHashInfo.ts @@ -5,7 +5,13 @@ export class RelayHashInfo1735922359359 implements MigrationInterface { public async up(queryRunner: QueryRunner): Promise { await queryRunner.query( - `ALTER TABLE "relay_hash_info" ADD "bridgeFeeUsd" character varying`, + `ALTER TABLE "relay_hash_info" ADD "bridgeFeeUsd" double precision`, + ); + await queryRunner.query( + `ALTER TABLE "relay_hash_info" ADD "inputPriceUsd" double precision`, + ); + await queryRunner.query( + `ALTER TABLE "relay_hash_info" ADD "outputPriceUsd" double precision`, ); } @@ -13,5 +19,11 @@ export class RelayHashInfo1735922359359 implements MigrationInterface { await queryRunner.query( `ALTER TABLE "relay_hash_info" DROP COLUMN "bridgeFeeUsd"`, ); + await queryRunner.query( + `ALTER TABLE "relay_hash_info" DROP COLUMN "outputPriceUsd"`, + ); + await queryRunner.query( + `ALTER TABLE "relay_hash_info" DROP COLUMN "inputPriceUsd"`, + ); } } diff --git a/packages/indexer-database/src/migrations/1735924259108-RelayHashInfo.ts b/packages/indexer-database/src/migrations/1735924259108-RelayHashInfo.ts deleted file mode 100644 index 85838da..0000000 --- a/packages/indexer-database/src/migrations/1735924259108-RelayHashInfo.ts +++ /dev/null @@ -1,23 +0,0 @@ -import { MigrationInterface, QueryRunner } from "typeorm"; - -export class RelayHashInfo1735924259108 implements MigrationInterface { - name = "RelayHashInfo1735924259108"; - - public async up(queryRunner: QueryRunner): Promise { - await queryRunner.query( - `ALTER TABLE "relay_hash_info" ADD "inputPriceUsd" integer`, - ); - await queryRunner.query( - `ALTER TABLE "relay_hash_info" ADD "outputPriceUsd" integer`, - ); - } - - public async down(queryRunner: QueryRunner): Promise { - await queryRunner.query( - `ALTER TABLE "relay_hash_info" DROP COLUMN "outputPriceUsd"`, - ); - await queryRunner.query( - `ALTER TABLE "relay_hash_info" DROP COLUMN "inputPriceUsd"`, - ); - } -} diff --git a/packages/indexer-database/src/migrations/1736274243965-RelayHashInfo.ts b/packages/indexer-database/src/migrations/1736274243965-RelayHashInfo.ts deleted file mode 100644 index b6fb15b..0000000 --- a/packages/indexer-database/src/migrations/1736274243965-RelayHashInfo.ts +++ /dev/null @@ -1,55 +0,0 @@ -import { MigrationInterface, QueryRunner } from "typeorm"; - -export class RelayHashInfo1736274243965 implements MigrationInterface { - name = "RelayHashInfo1736274243965"; - - public async up(queryRunner: QueryRunner): Promise { - await queryRunner.query( - `ALTER TABLE "relay_hash_info" DROP COLUMN "bridgeFeeUsd"`, - ); - await queryRunner.query( - `ALTER TABLE "relay_hash_info" ADD "bridgeFeeUsd" double precision`, - ); - await queryRunner.query( - `ALTER TABLE "relay_hash_info" DROP COLUMN "inputPriceUsd"`, - ); - await queryRunner.query( - `ALTER TABLE "relay_hash_info" ADD "inputPriceUsd" double precision`, - ); - await queryRunner.query( - `ALTER TABLE "relay_hash_info" DROP COLUMN "outputPriceUsd"`, - ); - await queryRunner.query( - `ALTER TABLE "relay_hash_info" ADD "outputPriceUsd" double precision`, - ); - await queryRunner.query(`ALTER TABLE "historic_price" DROP COLUMN "price"`); - await queryRunner.query( - `ALTER TABLE "historic_price" ADD "price" double precision NOT NULL`, - ); - } - - public async down(queryRunner: QueryRunner): Promise { - await queryRunner.query(`ALTER TABLE "historic_price" DROP COLUMN "price"`); - await queryRunner.query( - `ALTER TABLE "historic_price" ADD "price" numeric NOT NULL`, - ); - await queryRunner.query( - `ALTER TABLE "relay_hash_info" DROP COLUMN "outputPriceUsd"`, - ); - await queryRunner.query( - `ALTER TABLE "relay_hash_info" ADD "outputPriceUsd" integer`, - ); - await queryRunner.query( - `ALTER TABLE "relay_hash_info" DROP COLUMN "inputPriceUsd"`, - ); - await queryRunner.query( - `ALTER TABLE "relay_hash_info" ADD "inputPriceUsd" integer`, - ); - await queryRunner.query( - `ALTER TABLE "relay_hash_info" DROP COLUMN "bridgeFeeUsd"`, - ); - await queryRunner.query( - `ALTER TABLE "relay_hash_info" ADD "bridgeFeeUsd" character varying`, - ); - } -}