## Database Migrations (18 new) - Migrate all primary keys from SERIAL to UUID - Add soft delete (deleted_at) to all 19 entities - Add missing indexes for performance optimization - Add CHECK constraints for data validation - Add user audit fields (last_login_at, timezone, locale) - Add weather station location fields (latitude, longitude, elevation) - Add foreign key relationships (CameraDevice→Device, ValidatedEvent→WeatherStation) - Prepare private key encryption fields ## Backend Entity Updates - All entities updated with UUID primary keys - Added @DeleteDateColumn for soft delete support - Updated relations and foreign key types ## Backend Service/Controller Updates - Changed ID parameters from number to string (UUID) - Removed ParseIntPipe from controllers - Updated TypeORM queries for string IDs ## Frontend Updates - Updated all service interfaces to use string IDs - Fixed CameraDevice.location as JSONB object - Updated weather.ts with new fields (elevation, timezone) - Added Supabase integration hooks and lib - Fixed chart components for new data structure ## Cleanup - Removed deprecated .claude/agents configuration files 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
85 lines
2.6 KiB
TypeScript
85 lines
2.6 KiB
TypeScript
import {
|
|
Entity,
|
|
PrimaryGeneratedColumn,
|
|
Column,
|
|
CreateDateColumn,
|
|
UpdateDateColumn,
|
|
DeleteDateColumn,
|
|
OneToMany,
|
|
Index,
|
|
} from 'typeorm';
|
|
import { WeatherForecast } from './weather-forecast.entity';
|
|
import { WeatherObservation } from './weather-observation.entity';
|
|
|
|
@Entity('weather_stations')
|
|
export class WeatherStation {
|
|
// Changed from serial to UUID in migration 1766300000006-1766300000008
|
|
@PrimaryGeneratedColumn('uuid')
|
|
id: string;
|
|
|
|
@Column({ name: 'station_name' })
|
|
@Index('idx_weather_stations_name')
|
|
stationName: string;
|
|
|
|
// Location coordinates (added in migration 1766300000001)
|
|
@Column({ type: 'decimal', precision: 10, scale: 7, nullable: true })
|
|
latitude?: number;
|
|
|
|
@Column({ type: 'decimal', precision: 10, scale: 7, nullable: true })
|
|
longitude?: number;
|
|
|
|
@Column({ type: 'decimal', precision: 6, scale: 1, nullable: true })
|
|
elevation?: number;
|
|
|
|
@Column({ type: 'varchar', length: 50, nullable: true })
|
|
timezone?: string;
|
|
|
|
@Column({ name: 'current_temperature', type: 'decimal', precision: 4, scale: 1, nullable: true })
|
|
currentTemperature?: number;
|
|
|
|
@Column({ type: 'integer', nullable: true })
|
|
humidity?: number;
|
|
|
|
@Column({ name: 'cloud_cover', type: 'integer', nullable: true })
|
|
cloudCover?: number;
|
|
|
|
@Column({ type: 'decimal', precision: 5, scale: 1, nullable: true })
|
|
visibility?: number;
|
|
|
|
@Column({ name: 'wind_speed', type: 'decimal', precision: 5, scale: 1, nullable: true })
|
|
windSpeed?: number;
|
|
|
|
@Column({ name: 'wind_direction', type: 'integer', nullable: true })
|
|
windDirection?: number;
|
|
|
|
@Column({ length: 50, nullable: true })
|
|
condition?: string;
|
|
|
|
@Column({ name: 'observation_quality', length: 20, nullable: true })
|
|
observationQuality?: string;
|
|
|
|
// Audit fields (added in migration 1766300000014)
|
|
@Column({ name: 'created_by', type: 'uuid', nullable: true })
|
|
createdBy?: string;
|
|
|
|
@Column({ name: 'updated_by', type: 'uuid', nullable: true })
|
|
updatedBy?: string;
|
|
|
|
@CreateDateColumn({ name: 'created_at', type: 'timestamptz' })
|
|
createdAt: Date;
|
|
|
|
@UpdateDateColumn({ name: 'updated_at', type: 'timestamptz' })
|
|
updatedAt: Date;
|
|
|
|
// Soft delete support (added in migration 1766300000005)
|
|
@DeleteDateColumn({ name: 'deleted_at', type: 'timestamptz', nullable: true })
|
|
@Index('idx_weather_stations_deleted_at', { where: 'deleted_at IS NULL' })
|
|
deletedAt?: Date;
|
|
|
|
@OneToMany(() => WeatherForecast, (forecast) => forecast.weatherStation)
|
|
forecasts: WeatherForecast[];
|
|
|
|
@OneToMany(() => WeatherObservation, (observation) => observation.weatherStation)
|
|
observations: WeatherObservation[];
|
|
}
|