import { MigrationInterface, QueryRunner, TableColumn } from 'typeorm';

export class AlterAppUsersTableToAddAccessTokenColumn1713865637138
  implements MigrationInterface
{
  public async up(queryRunner: QueryRunner): Promise<void> {
    await queryRunner.addColumn(
      'app_users',
      new TableColumn({
        name: 'access_token',
        type: 'varchar',
        isNullable: true,
      }),
    ),
      await queryRunner.addColumn(
        'app_users',
        new TableColumn({
          name: 'access_token_expiry',
          type: 'varchar',
          isNullable: true,
        }),
      ),
      await queryRunner.addColumn(
        'app_users',
        new TableColumn({
          name: 'refresh_token',
          type: 'varchar',
          isNullable: true,
        }),
      ),
      await queryRunner.addColumn(
        'app_users',
        new TableColumn({
          name: 'refresh_token_expiry',
          type: 'varchar',
          isNullable: true,
        }),
      );
  }

  public async down(queryRunner: QueryRunner): Promise<void> {
    await queryRunner.dropColumn('app_users', 'access_token');
    await queryRunner.dropColumn('app_users', 'access_token_expiry');
    await queryRunner.dropColumn('app_users', 'refresh_token');
    await queryRunner.dropColumn('app_users', 'refresh_token_expiry');
  }
}
