/* eslint-disable @typescript-eslint/no-unused-vars */
/* eslint-disable @typescript-eslint/no-empty-function */
import type { MigrationInterface, QueryRunner } from 'typeorm';

export class AddScheduleTimeIntervalService1740479281651 implements MigrationInterface {
  public async up(queryRunner: QueryRunner): Promise<void> {
    await queryRunner.query(`
      create table if not exists schedule_time_interval (
        id integer generated by default as identity,
        account_id integer not null,
        schedule_id integer not null,
        day_of_week text not null,
        time_from time without time zone not null,
        time_to time without time zone not null,
        primary key (id),
        foreign key (account_id) references account(id) on delete cascade,
        foreign key (schedule_id) references schedule(id) on delete cascade
      );

      create index if not exists idx_account_schedule on schedule_time_interval(account_id, schedule_id);
    `);
  }

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