import { Entity, PrimaryColumn, Column, CreateDateColumn, UpdateDateColumn, Index } from 'typeorm';

@Entity('blog_posts')
@Index(['status', 'published_at'])
@Index(['slug'], { unique: true })
export class BlogPostOrmEntity {
  @PrimaryColumn('uuid')
  id: string;

  @Column('varchar', { length: 255 })
  title: string;

  @Column('varchar', { length: 255, unique: true })
  slug: string;

  @Column('text')
  excerpt: string;

  @Column('text')
  content: string;

  @Column('varchar', { length: 500, nullable: true })
  cover_image_url?: string;

  @Column('varchar', { length: 50 })
  category: string;

  @Column('jsonb', { default: [] })
  tags: string[];

  @Column('varchar', { length: 255 })
  author_name: string;

  @Column('varchar', { length: 20, default: 'draft' })
  status: string;

  @Column('boolean', { default: false })
  is_featured: boolean;

  @Column('timestamp', { nullable: true })
  published_at?: Date;

  @CreateDateColumn()
  created_at: Date;

  @UpdateDateColumn()
  updated_at: Date;
}
