import { MigrationInterface, QueryRunner } from "typeorm"; export class AddREseller1775992337764 implements MigrationInterface { name = 'AddREseller1775992337764' public async up(queryRunner: QueryRunner): Promise { await queryRunner.query(`CREATE TABLE "reseller" ("id" uuid NOT NULL DEFAULT uuid_generate_v4(), "createdAt" TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(), "updatedAt" TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(), "name" character varying(100) NOT NULL, "ownerId" uuid, CONSTRAINT "UQ_4993ba05f9437d2c32ea8adde42" UNIQUE ("name"), CONSTRAINT "REL_e2c8deee8c9000aefd91c17486" UNIQUE ("ownerId"), CONSTRAINT "PK_fbb203c7b490e89a011e62f2faf" PRIMARY KEY ("id"))`); await queryRunner.query(`ALTER TABLE "user" ADD "resellerId" uuid`); await queryRunner.query(`ALTER TABLE "reseller" ADD CONSTRAINT "FK_e2c8deee8c9000aefd91c174860" FOREIGN KEY ("ownerId") REFERENCES "user"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`); await queryRunner.query(`ALTER TABLE "user" ADD CONSTRAINT "FK_f39518997d27b06d20bd1b08af0" FOREIGN KEY ("resellerId") REFERENCES "reseller"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`); } public async down(queryRunner: QueryRunner): Promise { await queryRunner.query(`ALTER TABLE "user" DROP CONSTRAINT "FK_f39518997d27b06d20bd1b08af0"`); await queryRunner.query(`ALTER TABLE "reseller" DROP CONSTRAINT "FK_e2c8deee8c9000aefd91c174860"`); await queryRunner.query(`ALTER TABLE "user" DROP COLUMN "resellerId"`); await queryRunner.query(`DROP TABLE "reseller"`); } }