import { Entity, PrimaryGeneratedColumn, Column, ManyToOne, JoinColumn, Unique } from 'typeorm';
import { License } from './license.entity';
import { MapLibrary } from './map-library.entity';

@Entity('map_rotations')
@Unique(['license_id', 'rotation_order'])
export class MapRotation {
  @PrimaryGeneratedColumn('uuid')
  id: string;

  @Column({ type: 'uuid' })
  license_id: string;

  @Column({ type: 'uuid' })
  map_id: string;

  @Column({ type: 'integer', default: 0 })
  rotation_order: number;

  @Column({ type: 'boolean', default: true })
  is_active: boolean;

  @ManyToOne(() => License, { onDelete: 'CASCADE' })
  @JoinColumn({ name: 'license_id' })
  license: License;

  @ManyToOne(() => MapLibrary, { onDelete: 'CASCADE' })
  @JoinColumn({ name: 'map_id' })
  map: MapLibrary;
}
