Skip to content

Commit

Permalink
feat: Added new migration for the new indexes, entity, constraints an…
Browse files Browse the repository at this point in the history
…d fields.
  • Loading branch information
brunomenezes committed Aug 22, 2024
1 parent 21aee7e commit 389a3fd
Showing 1 changed file with 85 additions and 0 deletions.
85 changes: 85 additions & 0 deletions db/migrations/1724312923354-Data.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
module.exports = class Data1724312923354 {
name = 'Data1724312923354'

async up(db) {
await db.query(`CREATE TABLE "chain" ("id" character varying NOT NULL, CONSTRAINT "PK_8e273aafae283b886672c952ecd" PRIMARY KEY ("id"))`)
await db.query(`ALTER TABLE "token" ADD "address" text NOT NULL`)
await db.query(`ALTER TABLE "token" ADD "chain_id" character varying`)
await db.query(`ALTER TABLE "erc20_deposit" ADD "chain_id" character varying`)
await db.query(`ALTER TABLE "nft" ADD "address" text NOT NULL`)
await db.query(`ALTER TABLE "nft" ADD "chain_id" character varying`)
await db.query(`ALTER TABLE "erc721_deposit" ADD "chain_id" character varying`)
await db.query(`ALTER TABLE "multi_token" ADD "address" text NOT NULL`)
await db.query(`ALTER TABLE "multi_token" ADD "chain_id" character varying`)
await db.query(`ALTER TABLE "erc1155_deposit" ADD "chain_id" character varying`)
await db.query(`ALTER TABLE "input" ADD "chain_id" character varying`)
await db.query(`ALTER TABLE "application" ADD "address" text NOT NULL`)
await db.query(`ALTER TABLE "application" ADD "chain_id" character varying`)
await db.query(`ALTER TABLE "application_factory" ADD "address" text NOT NULL`)
await db.query(`ALTER TABLE "application_factory" ADD "chain_id" character varying`)
await db.query(`CREATE INDEX "IDX_de7e0d7203642a7985ad1e5bf9" ON "token" ("chain_id") `)
await db.query(`CREATE INDEX "IDX_98e0e62905bf3179bdbf443735" ON "token" ("address", "chain_id") `)
await db.query(`CREATE INDEX "IDX_8f6b794ba2a2b727b1929bb557" ON "erc20_deposit" ("chain_id") `)
await db.query(`CREATE INDEX "IDX_1bcdd2b8e813324a2804544eb1" ON "nft" ("chain_id") `)
await db.query(`CREATE INDEX "IDX_bfc419f78ddfbf14a8daef4abd" ON "nft" ("address", "chain_id") `)
await db.query(`CREATE INDEX "IDX_01a73626515aef160a3049a788" ON "erc721_deposit" ("chain_id") `)
await db.query(`CREATE INDEX "IDX_a0b30e82e31660302a4af8cbe2" ON "multi_token" ("chain_id") `)
await db.query(`CREATE INDEX "IDX_3d12b347a7a916b6975b8b6737" ON "multi_token" ("address", "chain_id") `)
await db.query(`CREATE INDEX "IDX_732c4624c6d3a7de141edf6f73" ON "erc1155_deposit" ("chain_id") `)
await db.query(`CREATE INDEX "IDX_cf5fb31b5cf6719dc28adbb7d1" ON "input" ("chain_id") `)
await db.query(`CREATE INDEX "IDX_29002c32f1d054e8f0ec4ea9cd" ON "input" ("id", "chain_id") `)
await db.query(`CREATE INDEX "IDX_13e23630dd6edeb8dd7062483f" ON "application" ("chain_id") `)
await db.query(`CREATE INDEX "IDX_6b4911d2e20363e9d2b4b24178" ON "application" ("address", "chain_id") `)
await db.query(`CREATE INDEX "IDX_402986e1692e825c3c773a56d6" ON "application_factory" ("chain_id") `)
await db.query(`ALTER TABLE "token" ADD CONSTRAINT "FK_de7e0d7203642a7985ad1e5bf97" FOREIGN KEY ("chain_id") REFERENCES "chain"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`)
await db.query(`ALTER TABLE "erc20_deposit" ADD CONSTRAINT "FK_8f6b794ba2a2b727b1929bb5571" FOREIGN KEY ("chain_id") REFERENCES "chain"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`)
await db.query(`ALTER TABLE "nft" ADD CONSTRAINT "FK_1bcdd2b8e813324a2804544eb1b" FOREIGN KEY ("chain_id") REFERENCES "chain"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`)
await db.query(`ALTER TABLE "erc721_deposit" ADD CONSTRAINT "FK_01a73626515aef160a3049a7884" FOREIGN KEY ("chain_id") REFERENCES "chain"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`)
await db.query(`ALTER TABLE "multi_token" ADD CONSTRAINT "FK_a0b30e82e31660302a4af8cbe2f" FOREIGN KEY ("chain_id") REFERENCES "chain"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`)
await db.query(`ALTER TABLE "erc1155_deposit" ADD CONSTRAINT "FK_732c4624c6d3a7de141edf6f732" FOREIGN KEY ("chain_id") REFERENCES "chain"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`)
await db.query(`ALTER TABLE "input" ADD CONSTRAINT "FK_cf5fb31b5cf6719dc28adbb7d1b" FOREIGN KEY ("chain_id") REFERENCES "chain"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`)
await db.query(`ALTER TABLE "application" ADD CONSTRAINT "FK_13e23630dd6edeb8dd7062483f5" FOREIGN KEY ("chain_id") REFERENCES "chain"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`)
await db.query(`ALTER TABLE "application_factory" ADD CONSTRAINT "FK_402986e1692e825c3c773a56d62" FOREIGN KEY ("chain_id") REFERENCES "chain"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`)
}

async down(db) {
await db.query(`DROP TABLE "chain"`)
await db.query(`ALTER TABLE "token" DROP COLUMN "address"`)
await db.query(`ALTER TABLE "token" DROP COLUMN "chain_id"`)
await db.query(`ALTER TABLE "erc20_deposit" DROP COLUMN "chain_id"`)
await db.query(`ALTER TABLE "nft" DROP COLUMN "address"`)
await db.query(`ALTER TABLE "nft" DROP COLUMN "chain_id"`)
await db.query(`ALTER TABLE "erc721_deposit" DROP COLUMN "chain_id"`)
await db.query(`ALTER TABLE "multi_token" DROP COLUMN "address"`)
await db.query(`ALTER TABLE "multi_token" DROP COLUMN "chain_id"`)
await db.query(`ALTER TABLE "erc1155_deposit" DROP COLUMN "chain_id"`)
await db.query(`ALTER TABLE "input" DROP COLUMN "chain_id"`)
await db.query(`ALTER TABLE "application" DROP COLUMN "address"`)
await db.query(`ALTER TABLE "application" DROP COLUMN "chain_id"`)
await db.query(`ALTER TABLE "application_factory" DROP COLUMN "address"`)
await db.query(`ALTER TABLE "application_factory" DROP COLUMN "chain_id"`)
await db.query(`DROP INDEX "public"."IDX_de7e0d7203642a7985ad1e5bf9"`)
await db.query(`DROP INDEX "public"."IDX_98e0e62905bf3179bdbf443735"`)
await db.query(`DROP INDEX "public"."IDX_8f6b794ba2a2b727b1929bb557"`)
await db.query(`DROP INDEX "public"."IDX_1bcdd2b8e813324a2804544eb1"`)
await db.query(`DROP INDEX "public"."IDX_bfc419f78ddfbf14a8daef4abd"`)
await db.query(`DROP INDEX "public"."IDX_01a73626515aef160a3049a788"`)
await db.query(`DROP INDEX "public"."IDX_a0b30e82e31660302a4af8cbe2"`)
await db.query(`DROP INDEX "public"."IDX_3d12b347a7a916b6975b8b6737"`)
await db.query(`DROP INDEX "public"."IDX_732c4624c6d3a7de141edf6f73"`)
await db.query(`DROP INDEX "public"."IDX_cf5fb31b5cf6719dc28adbb7d1"`)
await db.query(`DROP INDEX "public"."IDX_29002c32f1d054e8f0ec4ea9cd"`)
await db.query(`DROP INDEX "public"."IDX_13e23630dd6edeb8dd7062483f"`)
await db.query(`DROP INDEX "public"."IDX_6b4911d2e20363e9d2b4b24178"`)
await db.query(`DROP INDEX "public"."IDX_402986e1692e825c3c773a56d6"`)
await db.query(`ALTER TABLE "token" DROP CONSTRAINT "FK_de7e0d7203642a7985ad1e5bf97"`)
await db.query(`ALTER TABLE "erc20_deposit" DROP CONSTRAINT "FK_8f6b794ba2a2b727b1929bb5571"`)
await db.query(`ALTER TABLE "nft" DROP CONSTRAINT "FK_1bcdd2b8e813324a2804544eb1b"`)
await db.query(`ALTER TABLE "erc721_deposit" DROP CONSTRAINT "FK_01a73626515aef160a3049a7884"`)
await db.query(`ALTER TABLE "multi_token" DROP CONSTRAINT "FK_a0b30e82e31660302a4af8cbe2f"`)
await db.query(`ALTER TABLE "erc1155_deposit" DROP CONSTRAINT "FK_732c4624c6d3a7de141edf6f732"`)
await db.query(`ALTER TABLE "input" DROP CONSTRAINT "FK_cf5fb31b5cf6719dc28adbb7d1b"`)
await db.query(`ALTER TABLE "application" DROP CONSTRAINT "FK_13e23630dd6edeb8dd7062483f5"`)
await db.query(`ALTER TABLE "application_factory" DROP CONSTRAINT "FK_402986e1692e825c3c773a56d62"`)
}
}

0 comments on commit 389a3fd

Please sign in to comment.