import { Entity, PrimaryGeneratedColumn, Column, ManyToOne, JoinColumn, CreateDateColumn, DeleteDateColumn, Index, } from 'typeorm'; import { WeatherStation } from './weather-station.entity'; @Entity('weather_observations') export class WeatherObservation { // Changed from serial to UUID in migration 1766300000006-1766300000008 @PrimaryGeneratedColumn('uuid') id: string; // Changed from number to UUID in migration 1766300000007-1766300000008 @Column({ name: 'weather_station_id', type: 'uuid' }) @Index('idx_weather_observations_station_id') weatherStationId: string; @ManyToOne(() => WeatherStation, (station) => station.observations, { onDelete: 'CASCADE' }) @JoinColumn({ name: 'weather_station_id' }) weatherStation: WeatherStation; @Column({ name: 'observation_time', type: 'timestamptz' }) @Index('idx_weather_observations_time') observationTime: Date; @Column({ type: 'decimal', precision: 5, scale: 2 }) temperature: number; @Column({ type: 'decimal', precision: 5, scale: 2 }) humidity: number; @Column({ name: 'cloud_cover', type: 'decimal', precision: 5, scale: 2 }) cloudCover: number; @Column({ type: 'decimal', precision: 6, scale: 2 }) visibility: number; @Column({ name: 'wind_speed', type: 'decimal', precision: 5, scale: 2 }) windSpeed: number; @Column({ name: 'wind_direction', type: 'int' }) windDirection: number; @Column() condition: string; @Column({ name: 'observation_quality' }) observationQuality: 'excellent' | 'moderate' | 'poor'; @Column({ type: 'decimal', precision: 7, scale: 2 }) pressure: number; @Column({ type: 'decimal', precision: 5, scale: 2 }) precipitation: number; @CreateDateColumn({ name: 'created_at', type: 'timestamptz' }) createdAt: Date; // Soft delete support (added in migration 1766300000005) @DeleteDateColumn({ name: 'deleted_at', type: 'timestamptz', nullable: true }) @Index('idx_weather_observations_deleted_at', { where: 'deleted_at IS NULL' }) deletedAt?: Date; }