import { MigrationInterface, QueryRunner } from "typeorm";

export class ClientPricingEntity1753273304899 implements MigrationInterface {
    name = 'ClientPricingEntity1753273304899'

    public async up(queryRunner: QueryRunner): Promise<void> {
        await queryRunner.query(`CREATE TABLE \`client_pricing_tiers\` (\`id\` int NOT NULL AUTO_INCREMENT, \`name\` varchar(100) NOT NULL, \`hookline\` varchar(255) NULL, \`main_features\` text NULL, \`price\` decimal(10,2) NOT NULL, \`pricingId\` int NOT NULL, INDEX \`IDX_697c3dca710c7d5559848dbfad\` (\`name\`), PRIMARY KEY (\`id\`)) ENGINE=InnoDB`);
        await queryRunner.query(`CREATE TABLE \`client_pricing\` (\`id\` int NOT NULL AUTO_INCREMENT, \`title\` varchar(255) NOT NULL, \`subtitle\` varchar(255) NOT NULL, \`main_features\` text NULL, \`icon\` varchar(255) NOT NULL, PRIMARY KEY (\`id\`)) ENGINE=InnoDB`);
        await queryRunner.query(`ALTER TABLE \`client_pricing_tiers\` ADD CONSTRAINT \`FK_5d8f5b63c8f92efb9c360228351\` FOREIGN KEY (\`pricingId\`) REFERENCES \`client_pricing\`(\`id\`) ON DELETE CASCADE ON UPDATE NO ACTION`);
    }

    public async down(queryRunner: QueryRunner): Promise<void> {
        await queryRunner.query(`ALTER TABLE \`client_pricing_tiers\` DROP FOREIGN KEY \`FK_5d8f5b63c8f92efb9c360228351\``);
        await queryRunner.query(`DROP TABLE \`client_pricing\``);
        await queryRunner.query(`DROP INDEX \`IDX_697c3dca710c7d5559848dbfad\` ON \`client_pricing_tiers\``);
        await queryRunner.query(`DROP TABLE \`client_pricing_tiers\``);
    }

}
