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

export class AddSeoFieldsToBlogPosts1747000000000 implements MigrationInterface {
  public async up(queryRunner: QueryRunner): Promise<void> {
    await queryRunner.addColumns('blog_posts', [
      new TableColumn({
        name: 'meta_title',
        type: 'varchar',
        length: '255',
        isNullable: true,
      }),
      new TableColumn({
        name: 'meta_description',
        type: 'varchar',
        length: '500',
        isNullable: true,
      }),
      new TableColumn({
        name: 'primary_keyword',
        type: 'varchar',
        length: '255',
        isNullable: true,
      }),
      new TableColumn({
        name: 'secondary_keywords',
        type: 'jsonb',
        isNullable: false,
        default: "'[]'",
      }),
    ]);
  }

  public async down(queryRunner: QueryRunner): Promise<void> {
    await queryRunner.dropColumns('blog_posts', [
      'meta_title',
      'meta_description',
      'primary_keyword',
      'secondary_keywords',
    ]);
  }
}
