import { MigrationInterface, QueryRunner } from "typeorm";

export class InitialSchema1788757441596 implements MigrationInterface {
    name = 'InitialSchema1788757441596'

    public async up(queryRunner: QueryRunner): Promise<void> {
        await queryRunner.query(`CREATE TABLE \`service\` (\`id\` int NOT NULL AUTO_INCREMENT, \`name\` varchar(255) NOT NULL, \`subName\` text NOT NULL, \`expectedOutcomeMessage\` text NOT NULL, \`slug\` varchar(255) NOT NULL, \`badge\` varchar(255) NULL, \`thumbnailUrl\` varchar(255) NULL, \`description\` text NULL, \`longDescription\` text NOT NULL, \`tags\` text NULL, \`footerText\` varchar(255) NULL, \`landingHtml\` text NULL, \`parentId\` int NULL, UNIQUE INDEX \`IDX_7806a14d42c3244064b4a1706c\` (\`name\`), UNIQUE INDEX \`IDX_4df47ef659e04d5be78ddb6b59\` (\`slug\`), PRIMARY KEY (\`id\`)) ENGINE=InnoDB`);
        await queryRunner.query(`ALTER TABLE \`service\` ADD CONSTRAINT \`FK_c5906ffd2cd6fa558710901e4d0\` FOREIGN KEY (\`parentId\`) REFERENCES \`service\`(\`id\`) ON DELETE CASCADE ON UPDATE NO ACTION`);
    }

    public async down(queryRunner: QueryRunner): Promise<void> {
        await queryRunner.query(`ALTER TABLE \`service\` DROP FOREIGN KEY \`FK_c5906ffd2cd6fa558710901e4d0\``);
        await queryRunner.query(`DROP INDEX \`IDX_4df47ef659e04d5be78ddb6b59\` ON \`service\``);
        await queryRunner.query(`DROP INDEX \`IDX_7806a14d42c3244064b4a1706c\` ON \`service\``);
        await queryRunner.query(`DROP TABLE \`service\``);
    }

}
