import { MigrationInterface, QueryRunner } from 'typeorm';

export class assetAndWorkspaceIndices1701963337389
  implements MigrationInterface
{
  public async up(queryRunner: QueryRunner): Promise<void> {
    await queryRunner.query(`
            alter table assets
            add index float4;
        `);
    await queryRunner.query(`
            alter table workspaces
            add index float4;
        `);
    await queryRunner.query(`
            alter table asset_blocks 
            alter column index type float4 using index::float4;
        `);
    await queryRunner.query(`
            alter table task_columns 
            alter column index type float4 using index::float4;
        `);
  }

  public async down(queryRunner: QueryRunner): Promise<void> {
    await queryRunner.query(`
            alter table assets
            drop column index;
        `);
    await queryRunner.query(`
            alter table workspaces
            drop column index;
        `);
    await queryRunner.query(`
            alter table asset_blocks 
            alter column index type int using index::int;
        `);
    await queryRunner.query(`
            alter table task_columns 
            alter column index type int using index::int;
        `);
  }
}
