import { MigrationInterface, QueryRunner } from 'typeorm';

export class createProductNotifQuantityTable1663152263809
  implements MigrationInterface
{
  name = 'createProductNotifQuantityTable1663152263809';

  public async up(queryRunner: QueryRunner): Promise<void> {
    await queryRunner.query(`
CREATE TABLE IF NOT EXISTS \`product_notif_quantities\` (
  \`id\` INT(11) NOT NULL AUTO_INCREMENT,
  \`userId\` CHAR(36) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,
  \`productId\` CHAR(36) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,
  \`status\` ENUM('pending', 'done') NOT NULL DEFAULT 'pending',
  \`createdAt\` DATETIME NOT NULL,
  \`updatedAt\` DATETIME NOT NULL,
  INDEX \`fk_product_notif_quantities_users1_idx\` (\`userId\` ASC),
  INDEX \`fk_product_notif_quantities_products1_idx\` (\`productId\` ASC),
  PRIMARY KEY (\`id\`),
  CONSTRAINT \`fk_product_notif_quantities_users1\`
    FOREIGN KEY (\`userId\`)
    REFERENCES \`users\` (\`id\`)
    ON UPDATE CASCADE,
  CONSTRAINT \`fk_product_notif_quantities_products1\`
    FOREIGN KEY (\`productId\`)
    REFERENCES \`products\` (\`id\`)
    ON UPDATE CASCADE)
ENGINE = InnoDB
DEFAULT CHARACTER SET = utf8
COLLATE = utf8_unicode_ci;
`);
  }

  public async down(queryRunner: QueryRunner): Promise<void> {
    //
  }
}
