|
1 | 1 | import { type MigrationInterface, type QueryRunner } from "typeorm";
|
2 | 2 |
|
3 |
| -export class InitMigration1737614845281 implements MigrationInterface { |
4 |
| - name = 'InitMigration1737614845281' |
| 3 | +export class InitMigration1737626955612 implements MigrationInterface { |
| 4 | + name = 'InitMigration1737626955612' |
5 | 5 |
|
6 | 6 | public async up(queryRunner: QueryRunner): Promise<void> {
|
7 | 7 | await queryRunner.query(`CREATE TABLE "application" ("id" SERIAL NOT NULL, "chainId" integer NOT NULL, "alloApplicationId" character varying NOT NULL, "poolId" integer NOT NULL, CONSTRAINT "UQ_8849159f2a2681f6be67ef84efb" UNIQUE ("alloApplicationId", "poolId"), CONSTRAINT "PK_569e0c3e863ebdf5f2408ee1670" PRIMARY KEY ("id"))`);
|
8 | 8 | await queryRunner.query(`CREATE TYPE "public"."eligibility_criteria_eligibilitytype_enum" AS ENUM('linear')`);
|
9 | 9 | await queryRunner.query(`CREATE TABLE "eligibility_criteria" ("id" SERIAL NOT NULL, "chainId" integer NOT NULL, "alloPoolId" character varying NOT NULL, "eligibilityType" "public"."eligibility_criteria_eligibilitytype_enum" NOT NULL, "data" json NOT NULL, CONSTRAINT "UQ_cab3614863337cf5dba521b9b84" UNIQUE ("chainId", "alloPoolId"), CONSTRAINT "PK_231ea7a8a87bb6092eb3af1c5a8" PRIMARY KEY ("id"))`);
|
10 |
| - await queryRunner.query(`CREATE TABLE "pool" ("id" SERIAL NOT NULL, "chainId" integer NOT NULL, "alloPoolId" character varying NOT NULL, "metricIdentifiers" text, "distributionData" text, "eligibilityCriteriaId" integer, CONSTRAINT "UQ_72fcaa655b2b7348f4feaf25ea3" UNIQUE ("chainId", "alloPoolId"), CONSTRAINT "REL_bb4a5f9f4367c3de6ccaf665cc" UNIQUE ("eligibilityCriteriaId"), CONSTRAINT "PK_db1bfe411e1516c01120b85f8fe" PRIMARY KEY ("id"))`); |
11 | 10 | await queryRunner.query(`CREATE TABLE "vote" ("id" SERIAL NOT NULL, "voter" character varying(42) NOT NULL, "alloPoolId" character varying NOT NULL, "chainId" integer NOT NULL, "ballot" text NOT NULL, "poolId" integer NOT NULL, CONSTRAINT "UQ_3940f20660f872bfe5386def7f1" UNIQUE ("poolId", "voter"), CONSTRAINT "PK_2d5932d46afe39c8176f9d4be72" PRIMARY KEY ("id"))`);
|
| 11 | + await queryRunner.query(`CREATE TABLE "pool" ("id" SERIAL NOT NULL, "chainId" integer NOT NULL, "alloPoolId" character varying NOT NULL, "metricIdentifiers" text, "distributionData" text, "eligibilityCriteriaId" integer, CONSTRAINT "UQ_72fcaa655b2b7348f4feaf25ea3" UNIQUE ("chainId", "alloPoolId"), CONSTRAINT "REL_bb4a5f9f4367c3de6ccaf665cc" UNIQUE ("eligibilityCriteriaId"), CONSTRAINT "PK_db1bfe411e1516c01120b85f8fe" PRIMARY KEY ("id"))`); |
12 | 12 | await queryRunner.query(`CREATE TYPE "public"."metric_orientation_enum" AS ENUM('increase', 'decrease')`);
|
13 |
| - await queryRunner.query(`CREATE TABLE "metric" ("id" SERIAL NOT NULL, "identifier" character varying NOT NULL, "name" character varying NOT NULL, "description" character varying NOT NULL, "orientation" "public"."metric_orientation_enum" NOT NULL, "enabled" boolean NOT NULL DEFAULT false, CONSTRAINT "UQ_1136bb423acf02b4e7e5c909d0c" UNIQUE ("identifier"), CONSTRAINT "PK_7d24c075ea2926dd32bd1c534ce" PRIMARY KEY ("id"))`); |
| 13 | + await queryRunner.query(`CREATE TABLE "metric" ("id" SERIAL NOT NULL, "identifier" character varying NOT NULL, "title" character varying NOT NULL, "description" character varying NOT NULL, "orientation" "public"."metric_orientation_enum" NOT NULL, "enabled" boolean NOT NULL DEFAULT false, CONSTRAINT "UQ_1136bb423acf02b4e7e5c909d0c" UNIQUE ("identifier"), CONSTRAINT "PK_7d24c075ea2926dd32bd1c534ce" PRIMARY KEY ("id"))`); |
14 | 14 | await queryRunner.query(`ALTER TABLE "application" ADD CONSTRAINT "FK_a2d1c7a2c6ee681b42112d41284" FOREIGN KEY ("poolId") REFERENCES "pool"("id") ON DELETE CASCADE ON UPDATE NO ACTION`);
|
15 |
| - await queryRunner.query(`ALTER TABLE "pool" ADD CONSTRAINT "FK_bb4a5f9f4367c3de6ccaf665cc2" FOREIGN KEY ("eligibilityCriteriaId") REFERENCES "eligibility_criteria"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`); |
16 | 15 | await queryRunner.query(`ALTER TABLE "vote" ADD CONSTRAINT "FK_86b9c0ae3057aa451170728b2bb" FOREIGN KEY ("poolId") REFERENCES "pool"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`);
|
| 16 | + await queryRunner.query(`ALTER TABLE "pool" ADD CONSTRAINT "FK_bb4a5f9f4367c3de6ccaf665cc2" FOREIGN KEY ("eligibilityCriteriaId") REFERENCES "eligibility_criteria"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`); |
17 | 17 | }
|
18 | 18 |
|
19 | 19 | public async down(queryRunner: QueryRunner): Promise<void> {
|
20 |
| - await queryRunner.query(`ALTER TABLE "vote" DROP CONSTRAINT "FK_86b9c0ae3057aa451170728b2bb"`); |
21 | 20 | await queryRunner.query(`ALTER TABLE "pool" DROP CONSTRAINT "FK_bb4a5f9f4367c3de6ccaf665cc2"`);
|
| 21 | + await queryRunner.query(`ALTER TABLE "vote" DROP CONSTRAINT "FK_86b9c0ae3057aa451170728b2bb"`); |
22 | 22 | await queryRunner.query(`ALTER TABLE "application" DROP CONSTRAINT "FK_a2d1c7a2c6ee681b42112d41284"`);
|
23 | 23 | await queryRunner.query(`DROP TABLE "metric"`);
|
24 | 24 | await queryRunner.query(`DROP TYPE "public"."metric_orientation_enum"`);
|
25 |
| - await queryRunner.query(`DROP TABLE "vote"`); |
26 | 25 | await queryRunner.query(`DROP TABLE "pool"`);
|
| 26 | + await queryRunner.query(`DROP TABLE "vote"`); |
27 | 27 | await queryRunner.query(`DROP TABLE "eligibility_criteria"`);
|
28 | 28 | await queryRunner.query(`DROP TYPE "public"."eligibility_criteria_eligibilitytype_enum"`);
|
29 | 29 | await queryRunner.query(`DROP TABLE "application"`);
|
|
0 commit comments