import { MigrationInterface, QueryRunner } from 'typeorm';

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

  public async up(queryRunner: QueryRunner): Promise<void> {
    await queryRunner.query(
      `ALTER TABLE \`driving_offense_bills\` 
      ADD COLUMN \`paymentId\` INT(11) NULL DEFAULT NULL AFTER \`drivingOffenseId\`,
      CHANGE COLUMN \`status\` \`status\` ENUM('unpaid', 'paid', 'done') NOT NULL DEFAULT 'unpaid' ,
      ADD INDEX \`fk_driving_offense_bills_payments1_idx\` (\`paymentId\` ASC)`,
    );
    await queryRunner.query(
      `ALTER TABLE \`payments\` 
      CHANGE COLUMN \`type\` \`type\` ENUM('shop', 'service', 'oil_gov_service', 'oil_gov_shop', 'freeway_inquiry',
       'offense_inquiry', 'offense_pay', 'negative_inquiry') NULL DEFAULT NULL `,
    );
    await queryRunner.query(
      `ALTER TABLE \`driving_offense_bills\` 
      ADD CONSTRAINT \`fk_driving_offense_bills_payments1\`
        FOREIGN KEY (\`paymentId\`)
        REFERENCES \`payments\` (\`id\`)
        ON DELETE NO ACTION
        ON UPDATE NO ACTION`,
    );
  }

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