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

export class AddGoogleCalendarAccount1737378761002 implements MigrationInterface {
  public async up(queryRunner: QueryRunner): Promise<void> {
    await queryRunner.query(`
      create table google_calendar_account (
        id integer generated by default as identity,
        account_id integer not null,
        external_id text not null,
        tokens jsonb not null,
        sync_token text,
        channel_id text,
        channel_resource_id text,
        channel_expiration timestamp without time zone,
        primary key (id),
        foreign key (account_id) references account(id) on delete cascade
      );

      alter table google_calendar
        drop column tokens,
        add column calendar_account_id integer not null,
        add foreign key (calendar_account_id) references google_calendar_account(id);
    `);
  }

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