diff --git a/src/Heimdall.Agent/Services/CameraStreamService.cs b/src/Heimdall.Agent/Services/CameraStreamService.cs
new file mode 100644
index 0000000..9544f2b
--- /dev/null
+++ b/src/Heimdall.Agent/Services/CameraStreamService.cs
@@ -0,0 +1,153 @@
+using System.Diagnostics;
+using Microsoft.Extensions.Logging;
+
+namespace Heimdall.Agent.Services;
+
+///
+/// Manages RTSP stream connections for each assigned camera.
+/// Launches FFmpeg processes to capture frames and feeds them to
+/// the detection pipeline for analysis.
+///
+public sealed class CameraStreamService : IDisposable
+{
+ private readonly ILogger _logger;
+ private readonly Dictionary _sessions = [];
+ private readonly SemaphoreSlim _throttle = new(4, 4); // Max 4 concurrent FFmpeg
+
+ public CameraStreamService(ILogger logger)
+ {
+ _logger = logger;
+ }
+
+ /// Start streaming from a camera. Launches FFmpeg in the background.
+ public async Task StartStreamAsync(Guid cameraId, string rtspUrl, CancellationToken ct = default)
+ {
+ if (_sessions.ContainsKey(cameraId))
+ {
+ _logger.LogWarning("Stream already active for camera {CameraId}", cameraId);
+ return false;
+ }
+
+ await _throttle.WaitAsync(ct);
+ try
+ {
+ var psi = new ProcessStartInfo
+ {
+ FileName = "ffmpeg",
+ Arguments = $"-rtsp_transport tcp -i \"{rtspUrl}\" -f image2pipe -vcodec mjpeg -q:v 3 -update 1 -",
+ RedirectStandardOutput = true,
+ RedirectStandardError = true,
+ UseShellExecute = false,
+ CreateNoWindow = true,
+ };
+
+ var process = new Process { StartInfo = psi };
+ process.Start();
+
+ var session = new StreamSession(cameraId, rtspUrl, process);
+ _sessions[cameraId] = session;
+
+ _logger.LogInformation("Stream started for camera {CameraId}: {Url}", cameraId, rtspUrl);
+
+ // Background read loop
+ _ = Task.Run(() => ReadFramesLoop(cameraId, session, ct), ct);
+
+ return true;
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, "Failed to start stream for camera {CameraId}", cameraId);
+ _throttle.Release();
+ return false;
+ }
+ }
+
+ /// Stop streaming from a camera.
+ public Task StopStreamAsync(Guid cameraId)
+ {
+ if (_sessions.TryGetValue(cameraId, out var session))
+ {
+ session.Cancel();
+ _sessions.Remove(cameraId);
+ _throttle.Release();
+ _logger.LogInformation("Stream stopped for camera {CameraId}", cameraId);
+ }
+ return Task.CompletedTask;
+ }
+
+ /// Number of currently active streams.
+ public int ActiveStreamCount => _sessions.Count;
+
+ private Task ReadFramesLoop(Guid cameraId, StreamSession session, CancellationToken ct)
+ {
+ try
+ {
+ var buffer = new byte[256 * 1024]; // 256KB buffer
+ var stream = session.Process.StandardOutput.BaseStream;
+
+ while (!ct.IsCancellationRequested && !session.IsCancelled && !session.Process.HasExited)
+ {
+ var bytesRead = stream.Read(buffer, 0, buffer.Length);
+ if (bytesRead == 0) break;
+
+ // Frame available for analysis — will be passed to FrameAnalyzerService
+ // in a future phase. For now, we just count frames.
+ Interlocked.Increment(ref session.FrameCount);
+ }
+ }
+ catch (Exception ex) when (ex is not OperationCanceledException)
+ {
+ _logger.LogWarning(ex, "Frame read loop ended for camera {CameraId}", cameraId);
+ }
+ finally
+ {
+ CleanupSession(cameraId, session);
+ }
+
+ return Task.CompletedTask;
+ }
+
+ private void CleanupSession(Guid cameraId, StreamSession session)
+ {
+ try
+ {
+ if (!session.Process.HasExited)
+ {
+ session.Process.Kill(entireProcessTree: true);
+ session.Process.WaitForExit(2000);
+ }
+ session.Process.Dispose();
+ }
+ catch (Exception ex)
+ {
+ _logger.LogWarning(ex, "Cleanup error for camera {CameraId}", cameraId);
+ }
+ finally
+ {
+ _throttle.Release();
+ _sessions.Remove(cameraId);
+ }
+ }
+
+ public void Dispose()
+ {
+ foreach (var session in _sessions.Values)
+ {
+ session.Cancel();
+ session.Process?.Dispose();
+ }
+ _sessions.Clear();
+ _throttle.Dispose();
+ }
+
+ private sealed class StreamSession(Guid cameraId, string rtspUrl, Process process)
+ {
+ public Guid CameraId { get; } = cameraId;
+ public string RtspUrl { get; } = rtspUrl;
+ public Process Process { get; } = process;
+ public long FrameCount;
+ private volatile bool _cancelled;
+ public bool IsCancelled => _cancelled;
+ public void Cancel() => _cancelled = true;
+ }
+}
diff --git a/src/Heimdall.Api/Controllers/EventsController.cs b/src/Heimdall.Api/Controllers/EventsController.cs
new file mode 100644
index 0000000..5a9cb1c
--- /dev/null
+++ b/src/Heimdall.Api/Controllers/EventsController.cs
@@ -0,0 +1,113 @@
+using Heimdall.Application.DTOs;
+using Heimdall.Application.Services;
+using Heimdall.Domain.Enums;
+using Heimdall.Infrastructure.Security;
+using Microsoft.AspNetCore.Authorization;
+using Microsoft.AspNetCore.Mvc;
+using Microsoft.AspNetCore.RateLimiting;
+
+namespace Heimdall.Api.Controllers;
+
+///
+/// Camera detection events — motion, person, vehicle, face recognition, etc.
+/// Agents POST events as they detect them; users GET filtered views.
+///
+[ApiController]
+[Route("api/events")]
+[EnableRateLimiting("Api")]
+public class EventsController : ControllerBase
+{
+ private readonly ICameraEventService _eventService;
+
+ public EventsController(ICameraEventService eventService) => _eventService = eventService;
+
+ /// Record a new detection event (called by agents).
+ [Authorize(AuthenticationSchemes = "ApiKey", Policy = AppPermissions.CameraWrite)]
+ [HttpPost]
+ [ProducesResponseType(typeof(CameraEventResponse), StatusCodes.Status200OK)]
+ [ProducesResponseType(typeof(void), StatusCodes.Status400BadRequest)]
+ public async Task Create([FromBody] CreateCameraEventRequest request, CancellationToken ct)
+ {
+ var result = await _eventService.CreateAsync(request, ct);
+ return result.IsSuccess
+ ? Ok(result.Data)
+ : StatusCode(result.StatusCode ?? 400, new { error = result.Error });
+ }
+
+ /// Get a single event by ID.
+ [Authorize(AuthenticationSchemes = "JwtBearer", Policy = AppPermissions.CameraRead)]
+ [HttpGet("{id:guid}")]
+ [ProducesResponseType(typeof(CameraEventResponse), StatusCodes.Status200OK)]
+ [ProducesResponseType(typeof(void), StatusCodes.Status404NotFound)]
+ public async Task GetById(Guid id, CancellationToken ct)
+ {
+ var result = await _eventService.GetByIdAsync(id, ct);
+ return result.IsSuccess
+ ? Ok(result.Data)
+ : StatusCode(result.StatusCode ?? 404, new { error = result.Error });
+ }
+
+ /// Query events with filters. Supports pagination.
+ [Authorize(AuthenticationSchemes = "JwtBearer", Policy = AppPermissions.CameraRead)]
+ [HttpGet]
+ [ProducesResponseType(typeof(PagedResult), StatusCodes.Status200OK)]
+ public async Task Query(
+ [FromQuery] Guid? cameraId,
+ [FromQuery] Guid? siteId,
+ [FromQuery] string? type,
+ [FromQuery] DateTime? from,
+ [FromQuery] DateTime? to,
+ [FromQuery] double? minConfidence,
+ [FromQuery] int page = 1,
+ [FromQuery] int pageSize = 50,
+ CancellationToken ct = default)
+ {
+ EventType? parsedType = null;
+ if (type is not null && Enum.TryParse(type, true, out var t))
+ parsedType = t;
+
+ var filter = new CameraEventFilterRequest(cameraId, siteId, parsedType, from, to, minConfidence, page, pageSize);
+ var result = await _eventService.QueryAsync(filter, ct);
+ return Ok(result.Data);
+ }
+
+ /// Get recent events for a camera.
+ [Authorize(AuthenticationSchemes = "JwtBearer", Policy = AppPermissions.CameraRead)]
+ [HttpGet("camera/{cameraId:guid}")]
+ [ProducesResponseType(typeof(List), StatusCodes.Status200OK)]
+ public async Task GetRecentByCamera(Guid cameraId, [FromQuery] int count = 20, CancellationToken ct = default)
+ {
+ var result = await _eventService.GetRecentByCameraAsync(cameraId, count, ct);
+ return Ok(result.Data);
+ }
+
+ /// Attach a snapshot URL to an event (called by agents after upload).
+ [Authorize(AuthenticationSchemes = "ApiKey", Policy = AppPermissions.CameraWrite)]
+ [HttpPost("{id:guid}/snapshot")]
+ [ProducesResponseType(StatusCodes.Status200OK)]
+ [ProducesResponseType(typeof(void), StatusCodes.Status404NotFound)]
+ public async Task AttachSnapshot(Guid id, [FromBody] AttachSnapshotRequest request, CancellationToken ct)
+ {
+ var result = await _eventService.AttachSnapshotAsync(id, request.SnapshotUrl, request.ThumbUrl, ct);
+ return result.IsSuccess
+ ? Ok()
+ : StatusCode(result.StatusCode ?? 404, new { error = result.Error });
+ }
+
+ /// Delete an event.
+ [Authorize(AuthenticationSchemes = "JwtBearer", Policy = AppPermissions.CameraWrite)]
+ [HttpDelete("{id:guid}")]
+ [ProducesResponseType(StatusCodes.Status200OK)]
+ [ProducesResponseType(typeof(void), StatusCodes.Status404NotFound)]
+ public async Task Delete(Guid id, CancellationToken ct)
+ {
+ var result = await _eventService.DeleteAsync(id, ct);
+ return result.IsSuccess
+ ? Ok()
+ : StatusCode(result.StatusCode ?? 404, new { error = result.Error });
+ }
+}
+
+// ─── DTOs ───────────────────────────────────────────────────────────
+
+public record AttachSnapshotRequest(string SnapshotUrl, string? ThumbUrl);
diff --git a/src/Heimdall.Application/DTOs/CameraEventDto.cs b/src/Heimdall.Application/DTOs/CameraEventDto.cs
new file mode 100644
index 0000000..2415adc
--- /dev/null
+++ b/src/Heimdall.Application/DTOs/CameraEventDto.cs
@@ -0,0 +1,34 @@
+using Heimdall.Domain.Enums;
+
+namespace Heimdall.Application.DTOs;
+
+public record CameraEventResponse(
+ Guid Id,
+ Guid CameraId,
+ Guid? AgentId,
+ EventType Type,
+ double Confidence,
+ string? Label,
+ string? SnapshotUrl,
+ string? SnapshotThumbUrl,
+ string? MetadataJson,
+ DateTime OccurredAt,
+ DateTime CreatedAt);
+
+public record CreateCameraEventRequest(
+ Guid CameraId,
+ EventType Type,
+ double Confidence,
+ string? Label,
+ string? MetadataJson,
+ DateTime? OccurredAt);
+
+public record CameraEventFilterRequest(
+ Guid? CameraId,
+ Guid? SiteId,
+ EventType? Type,
+ DateTime? From,
+ DateTime? To,
+ double? MinConfidence,
+ int Page = 1,
+ int PageSize = 50);
diff --git a/src/Heimdall.Application/Services/ICameraEventService.cs b/src/Heimdall.Application/Services/ICameraEventService.cs
new file mode 100644
index 0000000..9d48c2c
--- /dev/null
+++ b/src/Heimdall.Application/Services/ICameraEventService.cs
@@ -0,0 +1,29 @@
+using Heimdall.Application.Common;
+using Heimdall.Application.DTOs;
+
+namespace Heimdall.Application.Services;
+
+///
+/// Manages camera-detected events (motion, person, vehicle, face, etc.)
+/// with snapshot storage and query/filter capabilities.
+///
+public interface ICameraEventService
+{
+ /// Record a new detection event.
+ Task> CreateAsync(CreateCameraEventRequest request, CancellationToken ct);
+
+ /// Get a single event by ID.
+ Task> GetByIdAsync(Guid id, CancellationToken ct);
+
+ /// Query events with filters. Max pageSize = 100.
+ Task>> QueryAsync(CameraEventFilterRequest filter, CancellationToken ct);
+
+ /// Get recent events for a camera (last N).
+ Task>> GetRecentByCameraAsync(Guid cameraId, int count = 20, CancellationToken ct = default);
+
+ /// Delete an event.
+ Task DeleteAsync(Guid id, CancellationToken ct);
+
+ /// Attach a snapshot URL to an event.
+ Task AttachSnapshotAsync(Guid eventId, string snapshotUrl, string? thumbUrl, CancellationToken ct);
+}
diff --git a/src/Heimdall.Domain/Entities/CameraEvent.cs b/src/Heimdall.Domain/Entities/CameraEvent.cs
new file mode 100644
index 0000000..78be47c
--- /dev/null
+++ b/src/Heimdall.Domain/Entities/CameraEvent.cs
@@ -0,0 +1,54 @@
+using Heimdall.Domain.Enums;
+using Heimdall.Domain.Primitives;
+
+namespace Heimdall.Domain.Entities;
+
+///
+/// An event detected on a camera stream — motion, person, vehicle, face, etc.
+/// Stores AI detection results with confidence, bounding boxes, and snapshots.
+///
+public class CameraEvent : Entity, IAuditableEntity
+{
+ public Guid CameraId { get; private set; }
+ public Guid? AgentId { get; private set; }
+ public EventType Type { get; private set; }
+ public double Confidence { get; private set; }
+ public string? Label { get; private set; } // Human-readable label (e.g. "John Doe", "AB-123-CD")
+ public string? SnapshotUrl { get; private set; } // S3 key or URL to snapshot image
+ public string? SnapshotThumbUrl { get; private set; } // Thumbnail S3 key or URL
+ public string? MetadataJson { get; private set; } // JSON: bounding boxes, track ID, etc.
+ public DateTime OccurredAt { get; private set; }
+
+ // Audit
+ public DateTime CreatedAt { get; set; }
+ public DateTime UpdatedAt { get; set; }
+
+ // Navigation
+ public Camera Camera { get; private set; } = null!;
+
+ private CameraEvent() { } // EF Core
+
+ public CameraEvent(Guid cameraId, EventType type, double confidence, DateTime? occurredAt = null)
+ : base(Guid.NewGuid())
+ {
+ CameraId = cameraId;
+ Type = type;
+ Confidence = confidence;
+ OccurredAt = occurredAt ?? DateTime.UtcNow;
+ }
+
+ public void SetSnapshot(string snapshotUrl, string? thumbUrl = null)
+ {
+ SnapshotUrl = snapshotUrl;
+ if (thumbUrl is not null)
+ SnapshotThumbUrl = thumbUrl;
+ }
+
+ public void SetMetadata(string? label, string? metadataJson)
+ {
+ Label = label;
+ MetadataJson = metadataJson;
+ }
+
+ public void AssignAgent(Guid agentId) => AgentId = agentId;
+}
diff --git a/src/Heimdall.Infrastructure/Data/AppDbContext.cs b/src/Heimdall.Infrastructure/Data/AppDbContext.cs
index af0a505..0ae1c64 100644
--- a/src/Heimdall.Infrastructure/Data/AppDbContext.cs
+++ b/src/Heimdall.Infrastructure/Data/AppDbContext.cs
@@ -32,6 +32,9 @@ public class AppDbContext : IdentityDbContext
// Assignment entities
public DbSet CameraAssignments => Set();
+ // Event entities
+ public DbSet CameraEvents => Set();
+
protected override void OnModelCreating(ModelBuilder builder)
{
base.OnModelCreating(builder);
diff --git a/src/Heimdall.Infrastructure/Data/Configurations/CameraEventConfiguration.cs b/src/Heimdall.Infrastructure/Data/Configurations/CameraEventConfiguration.cs
new file mode 100644
index 0000000..44bb1ce
--- /dev/null
+++ b/src/Heimdall.Infrastructure/Data/Configurations/CameraEventConfiguration.cs
@@ -0,0 +1,60 @@
+using Heimdall.Domain.Entities;
+using Microsoft.EntityFrameworkCore;
+using Microsoft.EntityFrameworkCore.Metadata.Builders;
+
+namespace Heimdall.Infrastructure.Data.Configurations;
+
+public class CameraEventConfiguration : IEntityTypeConfiguration
+{
+ public void Configure(EntityTypeBuilder builder)
+ {
+ builder.ToTable("camera_events");
+
+ builder.HasKey(e => e.Id);
+
+ builder.Property(e => e.Type)
+ .HasConversion()
+ .IsRequired();
+
+ builder.Property(e => e.Confidence)
+ .HasDefaultValue(0.0);
+
+ builder.Property(e => e.Label)
+ .HasMaxLength(200)
+ .IsUnicode(false);
+
+ builder.Property(e => e.SnapshotUrl)
+ .HasMaxLength(2000)
+ .IsUnicode(false);
+
+ builder.Property(e => e.SnapshotThumbUrl)
+ .HasMaxLength(2000)
+ .IsUnicode(false);
+
+ builder.Property(e => e.MetadataJson)
+ .HasColumnType("jsonb");
+
+ builder.Property(e => e.OccurredAt)
+ .IsRequired();
+
+ builder.Property(e => e.CreatedAt)
+ .HasDefaultValueSql("NOW()");
+
+ builder.Property(e => e.UpdatedAt)
+ .HasDefaultValueSql("NOW()");
+
+ // Indexes
+ builder.HasIndex(e => new { e.CameraId, e.OccurredAt })
+ .IsDescending(false, true); // Most recent first
+
+ builder.HasIndex(e => new { e.CameraId, e.Type });
+
+ builder.HasIndex(e => e.OccurredAt);
+
+ // Relationships
+ builder.HasOne(e => e.Camera)
+ .WithMany()
+ .HasForeignKey(e => e.CameraId)
+ .OnDelete(DeleteBehavior.Cascade);
+ }
+}
diff --git a/src/Heimdall.Infrastructure/DependencyInjection.cs b/src/Heimdall.Infrastructure/DependencyInjection.cs
index 07d8ebe..22e5547 100644
--- a/src/Heimdall.Infrastructure/DependencyInjection.cs
+++ b/src/Heimdall.Infrastructure/DependencyInjection.cs
@@ -96,6 +96,9 @@ public static class DependencyInjection
// Assignment services
services.AddScoped();
+ // Event services
+ services.AddScoped();
+
return services;
}
}
diff --git a/src/Heimdall.Infrastructure/Migrations/20260719125356_AddCameraEvents.Designer.cs b/src/Heimdall.Infrastructure/Migrations/20260719125356_AddCameraEvents.Designer.cs
new file mode 100644
index 0000000..202b76b
--- /dev/null
+++ b/src/Heimdall.Infrastructure/Migrations/20260719125356_AddCameraEvents.Designer.cs
@@ -0,0 +1,1457 @@
+//
+using System;
+using Heimdall.Infrastructure.Data;
+using Microsoft.EntityFrameworkCore;
+using Microsoft.EntityFrameworkCore.Infrastructure;
+using Microsoft.EntityFrameworkCore.Migrations;
+using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
+using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
+
+#nullable disable
+
+namespace Heimdall.Infrastructure.Migrations
+{
+ [DbContext(typeof(AppDbContext))]
+ [Migration("20260719125356_AddCameraEvents")]
+ partial class AddCameraEvents
+ {
+ ///
+ protected override void BuildTargetModel(ModelBuilder modelBuilder)
+ {
+#pragma warning disable 612, 618
+ modelBuilder
+ .HasAnnotation("ProductVersion", "10.0.10")
+ .HasAnnotation("Relational:MaxIdentifierLength", 63);
+
+ NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
+
+ modelBuilder.Entity("Heimdall.Domain.Entities.Agent", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("uuid");
+
+ b.Property("ApiKeyHash")
+ .HasMaxLength(128)
+ .IsUnicode(false)
+ .HasColumnType("character varying(128)");
+
+ b.Property("ApiKeyPrefix")
+ .HasMaxLength(8)
+ .IsUnicode(false)
+ .HasColumnType("character varying(8)");
+
+ b.Property("CpuCores")
+ .HasColumnType("integer");
+
+ b.Property("CreatedAt")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("timestamp with time zone")
+ .HasDefaultValueSql("NOW()");
+
+ b.Property("DeletedAt")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property("GpuType")
+ .IsRequired()
+ .HasMaxLength(20)
+ .IsUnicode(false)
+ .HasColumnType("character varying(20)");
+
+ b.Property("HasGpu")
+ .HasColumnType("boolean");
+
+ b.Property("Hostname")
+ .IsRequired()
+ .HasMaxLength(255)
+ .IsUnicode(false)
+ .HasColumnType("character varying(255)");
+
+ b.Property("IsDeleted")
+ .HasColumnType("boolean");
+
+ b.Property("LastHeartbeat")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property("MemoryMb")
+ .HasColumnType("bigint");
+
+ b.Property("Name")
+ .IsRequired()
+ .HasMaxLength(200)
+ .IsUnicode(false)
+ .HasColumnType("character varying(200)");
+
+ b.Property("PublicIp")
+ .HasMaxLength(45)
+ .IsUnicode(false)
+ .HasColumnType("character varying(45)");
+
+ b.Property("SiteId")
+ .HasColumnType("uuid");
+
+ b.Property("Status")
+ .IsRequired()
+ .HasMaxLength(20)
+ .IsUnicode(false)
+ .HasColumnType("character varying(20)");
+
+ b.Property("UpdatedAt")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("timestamp with time zone")
+ .HasDefaultValueSql("NOW()");
+
+ b.Property("Version")
+ .IsRequired()
+ .HasMaxLength(50)
+ .IsUnicode(false)
+ .HasColumnType("character varying(50)");
+
+ b.HasKey("Id");
+
+ b.HasIndex("LastHeartbeat")
+ .HasFilter("\"Status\" = 'Online'");
+
+ b.HasIndex("SiteId");
+
+ b.ToTable("agents", (string)null);
+ });
+
+ modelBuilder.Entity("Heimdall.Domain.Entities.AgentSetting", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("uuid");
+
+ b.Property("AgentId")
+ .HasColumnType("uuid")
+ .HasColumnName("agent_id");
+
+ b.Property("CreatedAt")
+ .HasColumnType("timestamp with time zone")
+ .HasColumnName("created_at");
+
+ b.Property("Key")
+ .IsRequired()
+ .HasMaxLength(200)
+ .HasColumnType("character varying(200)")
+ .HasColumnName("key");
+
+ b.Property("UpdatedAt")
+ .HasColumnType("timestamp with time zone")
+ .HasColumnName("updated_at");
+
+ b.Property("Value")
+ .IsRequired()
+ .HasColumnType("text")
+ .HasColumnName("value");
+
+ b.HasKey("Id");
+
+ b.HasIndex("AgentId", "Key")
+ .IsUnique();
+
+ b.ToTable("agent_settings", (string)null);
+ });
+
+ modelBuilder.Entity("Heimdall.Domain.Entities.ApiKey", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("uuid");
+
+ b.Property("CreatedAt")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("timestamp with time zone")
+ .HasDefaultValueSql("NOW()");
+
+ b.Property("CreatedByUserId")
+ .HasColumnType("uuid");
+
+ b.Property("Enabled")
+ .HasColumnType("boolean");
+
+ b.Property("ExpiresAt")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property("KeyHash")
+ .IsRequired()
+ .HasMaxLength(128)
+ .IsUnicode(false)
+ .HasColumnType("character varying(128)");
+
+ b.Property("KeyPrefix")
+ .IsRequired()
+ .HasMaxLength(8)
+ .IsUnicode(false)
+ .HasColumnType("character varying(8)");
+
+ b.Property("LastUsedAt")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property("SiteId")
+ .HasColumnType("uuid");
+
+ b.HasKey("Id");
+
+ b.HasIndex("KeyHash");
+
+ b.HasIndex("KeyPrefix");
+
+ b.HasIndex("SiteId");
+
+ b.ToTable("api_keys", (string)null);
+ });
+
+ modelBuilder.Entity("Heimdall.Domain.Entities.AppRole", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("uuid");
+
+ b.Property("ConcurrencyStamp")
+ .IsConcurrencyToken()
+ .HasColumnType("text");
+
+ b.Property("Name")
+ .HasMaxLength(256)
+ .HasColumnType("character varying(256)");
+
+ b.Property("NormalizedName")
+ .HasMaxLength(256)
+ .HasColumnType("character varying(256)");
+
+ b.HasKey("Id");
+
+ b.HasIndex("NormalizedName")
+ .IsUnique()
+ .HasDatabaseName("RoleNameIndex");
+
+ b.ToTable("roles", (string)null);
+ });
+
+ modelBuilder.Entity("Heimdall.Domain.Entities.AppSetting", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("uuid");
+
+ b.Property("AllowedValues")
+ .HasMaxLength(2000)
+ .HasColumnType("character varying(2000)")
+ .HasColumnName("allowed_values");
+
+ b.Property("Category")
+ .IsRequired()
+ .HasMaxLength(100)
+ .HasColumnType("character varying(100)")
+ .HasColumnName("category");
+
+ b.Property("CreatedAt")
+ .HasColumnType("timestamp with time zone")
+ .HasColumnName("created_at");
+
+ b.Property("Description")
+ .HasMaxLength(500)
+ .HasColumnType("character varying(500)")
+ .HasColumnName("description");
+
+ b.Property("Key")
+ .IsRequired()
+ .HasMaxLength(200)
+ .HasColumnType("character varying(200)")
+ .HasColumnName("key");
+
+ b.Property("UpdatedAt")
+ .HasColumnType("timestamp with time zone")
+ .HasColumnName("updated_at");
+
+ b.Property("Value")
+ .IsRequired()
+ .HasColumnType("text")
+ .HasColumnName("value");
+
+ b.Property("ValueType")
+ .IsRequired()
+ .HasMaxLength(50)
+ .HasColumnType("character varying(50)")
+ .HasColumnName("value_type");
+
+ b.HasKey("Id");
+
+ b.HasIndex("Key")
+ .IsUnique();
+
+ b.ToTable("app_settings", (string)null);
+ });
+
+ modelBuilder.Entity("Heimdall.Domain.Entities.AppUser", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("uuid");
+
+ b.Property("AccessFailedCount")
+ .HasColumnType("integer");
+
+ b.Property("ConcurrencyStamp")
+ .IsConcurrencyToken()
+ .HasColumnType("text");
+
+ b.Property("CreatedAt")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("timestamp with time zone")
+ .HasDefaultValueSql("NOW()");
+
+ b.Property("DisplayName")
+ .IsRequired()
+ .HasMaxLength(200)
+ .HasColumnType("character varying(200)");
+
+ b.Property("Email")
+ .HasMaxLength(256)
+ .HasColumnType("character varying(256)");
+
+ b.Property("EmailConfirmed")
+ .HasColumnType("boolean");
+
+ b.Property("Language")
+ .IsRequired()
+ .ValueGeneratedOnAdd()
+ .HasMaxLength(10)
+ .IsUnicode(false)
+ .HasColumnType("character varying(10)")
+ .HasDefaultValue("fr");
+
+ b.Property("LockoutEnabled")
+ .HasColumnType("boolean");
+
+ b.Property("LockoutEnd")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property("MustChangePassword")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("boolean")
+ .HasDefaultValue(false);
+
+ b.Property("NormalizedEmail")
+ .HasMaxLength(256)
+ .HasColumnType("character varying(256)");
+
+ b.Property("NormalizedUserName")
+ .HasMaxLength(256)
+ .HasColumnType("character varying(256)");
+
+ b.Property("PasswordHash")
+ .HasColumnType("text");
+
+ b.Property("PhoneNumber")
+ .HasColumnType("text");
+
+ b.Property("PhoneNumberConfirmed")
+ .HasColumnType("boolean");
+
+ b.Property("SecurityStamp")
+ .HasColumnType("text");
+
+ b.Property("Theme")
+ .ValueGeneratedOnAdd()
+ .HasMaxLength(20)
+ .IsUnicode(false)
+ .HasColumnType("character varying(20)")
+ .HasDefaultValue("Auto");
+
+ b.Property("TwoFactorEnabled")
+ .HasColumnType("boolean");
+
+ b.Property("UserName")
+ .HasMaxLength(256)
+ .HasColumnType("character varying(256)");
+
+ b.HasKey("Id");
+
+ b.HasIndex("NormalizedEmail")
+ .HasDatabaseName("EmailIndex");
+
+ b.HasIndex("NormalizedUserName")
+ .IsUnique()
+ .HasDatabaseName("UserNameIndex");
+
+ b.ToTable("users", (string)null);
+ });
+
+ modelBuilder.Entity("Heimdall.Domain.Entities.AuditLog", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("uuid");
+
+ b.Property("Action")
+ .IsRequired()
+ .HasMaxLength(100)
+ .IsUnicode(false)
+ .HasColumnType("character varying(100)");
+
+ b.Property("IpAddress")
+ .HasMaxLength(45)
+ .IsUnicode(false)
+ .HasColumnType("character varying(45)");
+
+ b.Property("NewValue")
+ .HasColumnType("text");
+
+ b.Property("OldValue")
+ .HasColumnType("text");
+
+ b.Property("ResourceId")
+ .HasMaxLength(100)
+ .IsUnicode(false)
+ .HasColumnType("character varying(100)");
+
+ b.Property("ResourceType")
+ .IsRequired()
+ .HasMaxLength(100)
+ .IsUnicode(false)
+ .HasColumnType("character varying(100)");
+
+ b.Property("Timestamp")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("timestamp with time zone")
+ .HasDefaultValueSql("NOW()");
+
+ b.Property("UserId")
+ .HasColumnType("uuid");
+
+ b.HasKey("Id");
+
+ b.HasIndex("Timestamp")
+ .IsDescending();
+
+ b.HasIndex("UserId");
+
+ b.HasIndex("ResourceType", "ResourceId", "Timestamp")
+ .IsDescending(false, false, true);
+
+ b.ToTable("audit_logs", (string)null);
+ });
+
+ modelBuilder.Entity("Heimdall.Domain.Entities.Camera", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("uuid");
+
+ b.Property("AgentId")
+ .HasColumnType("uuid");
+
+ b.Property("Capabilities")
+ .IsRequired()
+ .HasMaxLength(64)
+ .IsUnicode(false)
+ .HasColumnType("character varying(64)");
+
+ b.Property("CreatedAt")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("timestamp with time zone")
+ .HasDefaultValueSql("NOW()");
+
+ b.Property("DeletedAt")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property("DetectedType")
+ .IsRequired()
+ .HasMaxLength(20)
+ .IsUnicode(false)
+ .HasColumnType("character varying(20)");
+
+ b.Property("DiscoveryMethod")
+ .IsRequired()
+ .HasMaxLength(20)
+ .IsUnicode(false)
+ .HasColumnType("character varying(20)");
+
+ b.Property("HasAudio")
+ .HasColumnType("boolean");
+
+ b.Property("HasMotionDetection")
+ .HasColumnType("boolean");
+
+ b.Property("HasPtz")
+ .HasColumnType("boolean");
+
+ b.Property("HttpPort")
+ .HasColumnType("integer");
+
+ b.Property("IpAddress")
+ .HasMaxLength(45)
+ .HasColumnType("character varying(45)");
+
+ b.Property("IsDeleted")
+ .HasColumnType("boolean");
+
+ b.Property("LastDiscoveredAt")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property("LastStreamTestAt")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property("LastTestedCodecs")
+ .HasMaxLength(200)
+ .IsUnicode(false)
+ .HasColumnType("character varying(200)");
+
+ b.Property("LastTestedHeight")
+ .HasColumnType("integer");
+
+ b.Property("LastTestedLatencyMs")
+ .HasColumnType("bigint");
+
+ b.Property("LastTestedWidth")
+ .HasColumnType("integer");
+
+ b.Property("MacAddress")
+ .HasMaxLength(17)
+ .HasColumnType("character varying(17)");
+
+ b.Property("Manufacturer")
+ .HasMaxLength(100)
+ .HasColumnType("character varying(100)");
+
+ b.Property("Model")
+ .HasMaxLength(100)
+ .HasColumnType("character varying(100)");
+
+ b.Property("Name")
+ .IsRequired()
+ .HasMaxLength(200)
+ .IsUnicode(false)
+ .HasColumnType("character varying(200)");
+
+ b.Property("OnvifPort")
+ .HasColumnType("integer");
+
+ b.Property("RtspPort")
+ .HasColumnType("integer");
+
+ b.Property("RtspUrl")
+ .HasMaxLength(1000)
+ .IsUnicode(false)
+ .HasColumnType("character varying(1000)");
+
+ b.Property("SiteId")
+ .HasColumnType("uuid");
+
+ b.Property("Status")
+ .IsRequired()
+ .HasMaxLength(20)
+ .IsUnicode(false)
+ .HasColumnType("character varying(20)");
+
+ b.Property("SubRtspUrl")
+ .HasMaxLength(1000)
+ .IsUnicode(false)
+ .HasColumnType("character varying(1000)");
+
+ b.Property("UpdatedAt")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("timestamp with time zone")
+ .HasDefaultValueSql("NOW()");
+
+ b.HasKey("Id");
+
+ b.HasIndex("AgentId");
+
+ b.HasIndex("IpAddress");
+
+ b.HasIndex("MacAddress");
+
+ b.HasIndex("SiteId");
+
+ b.ToTable("cameras", (string)null);
+ });
+
+ modelBuilder.Entity("Heimdall.Domain.Entities.CameraAssignment", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("uuid");
+
+ b.Property("AgentId")
+ .HasColumnType("uuid");
+
+ b.Property("AssignedAt")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property("CameraId")
+ .HasColumnType("uuid");
+
+ b.Property("Reason")
+ .IsRequired()
+ .HasMaxLength(50)
+ .IsUnicode(false)
+ .HasColumnType("character varying(50)");
+
+ b.Property("ReleasedAt")
+ .HasColumnType("timestamp with time zone");
+
+ b.HasKey("Id");
+
+ b.HasIndex("AssignedAt");
+
+ b.HasIndex("AgentId", "ReleasedAt")
+ .HasFilter("\"ReleasedAt\" IS NULL");
+
+ b.HasIndex("CameraId", "ReleasedAt")
+ .IsUnique()
+ .HasFilter("\"ReleasedAt\" IS NULL");
+
+ b.ToTable("camera_assignments", (string)null);
+ });
+
+ modelBuilder.Entity("Heimdall.Domain.Entities.CameraCredentials", b =>
+ {
+ b.Property("CameraId")
+ .HasColumnType("uuid");
+
+ b.Property("CreatedAt")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("timestamp with time zone")
+ .HasDefaultValueSql("NOW()");
+
+ b.Property("OnvifPassword")
+ .IsRequired()
+ .HasMaxLength(500)
+ .IsUnicode(false)
+ .HasColumnType("character varying(500)");
+
+ b.Property("OnvifUsername")
+ .IsRequired()
+ .ValueGeneratedOnAdd()
+ .HasMaxLength(100)
+ .IsUnicode(false)
+ .HasColumnType("character varying(100)")
+ .HasDefaultValue("admin");
+
+ b.Property("RtspPassword")
+ .IsRequired()
+ .HasMaxLength(500)
+ .IsUnicode(false)
+ .HasColumnType("character varying(500)");
+
+ b.Property("RtspUsername")
+ .IsRequired()
+ .HasMaxLength(100)
+ .IsUnicode(false)
+ .HasColumnType("character varying(100)");
+
+ b.Property("UpdatedAt")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("timestamp with time zone")
+ .HasDefaultValueSql("NOW()");
+
+ b.HasKey("CameraId");
+
+ b.ToTable("camera_credentials", (string)null);
+ });
+
+ modelBuilder.Entity("Heimdall.Domain.Entities.CameraDetectionProfile", b =>
+ {
+ b.Property("CameraId")
+ .HasColumnType("uuid");
+
+ b.Property("ActiveIntervalMs")
+ .HasColumnType("integer");
+
+ b.Property("AnimalCooldownSec")
+ .HasColumnType("integer");
+
+ b.Property("DetectAnimal")
+ .HasColumnType("boolean");
+
+ b.Property("DetectMotion")
+ .HasColumnType("boolean");
+
+ b.Property("DetectPackage")
+ .HasColumnType("boolean");
+
+ b.Property("DetectPerson")
+ .HasColumnType("boolean");
+
+ b.Property("DetectVehicle")
+ .HasColumnType("boolean");
+
+ b.Property("FaceRecognition")
+ .HasColumnType("boolean");
+
+ b.Property("IdleIntervalMs")
+ .HasColumnType("integer");
+
+ b.Property("IoUThreshold")
+ .HasColumnType("double precision");
+
+ b.Property("LicensePlateRecognition")
+ .HasColumnType("boolean");
+
+ b.Property("MaxEventsPerMinute")
+ .HasColumnType("integer");
+
+ b.Property("MinConfidence")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("double precision")
+ .HasDefaultValue(0.40000000000000002);
+
+ b.Property("MotionIntervalMs")
+ .HasColumnType("integer");
+
+ b.Property("MotionThreshold")
+ .HasColumnType("double precision");
+
+ b.Property("PersonCooldownSec")
+ .HasColumnType("integer");
+
+ b.Property("RequireMotionForAI")
+ .HasColumnType("boolean");
+
+ b.Property("VehicleCooldownSec")
+ .HasColumnType("integer");
+
+ b.Property("YoloModel")
+ .IsRequired()
+ .ValueGeneratedOnAdd()
+ .HasMaxLength(50)
+ .IsUnicode(false)
+ .HasColumnType("character varying(50)")
+ .HasDefaultValue("yolov8n");
+
+ b.HasKey("CameraId");
+
+ b.ToTable("camera_detection_profiles", (string)null);
+ });
+
+ modelBuilder.Entity("Heimdall.Domain.Entities.CameraDiscoveryResult", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("uuid");
+
+ b.Property("DetectedType")
+ .IsRequired()
+ .HasMaxLength(20)
+ .IsUnicode(false)
+ .HasColumnType("character varying(20)");
+
+ b.Property("DiscoveryMethod")
+ .IsRequired()
+ .HasMaxLength(20)
+ .IsUnicode(false)
+ .HasColumnType("character varying(20)");
+
+ b.Property("HomeKitDeviceId")
+ .HasMaxLength(50)
+ .IsUnicode(false)
+ .HasColumnType("character varying(50)");
+
+ b.Property("HomeKitModel")
+ .HasMaxLength(200)
+ .IsUnicode(false)
+ .HasColumnType("character varying(200)");
+
+ b.Property("HomeKitName")
+ .HasMaxLength(200)
+ .IsUnicode(false)
+ .HasColumnType("character varying(200)");
+
+ b.Property("Hostname")
+ .HasMaxLength(255)
+ .IsUnicode(false)
+ .HasColumnType("character varying(255)");
+
+ b.Property("HttpPort")
+ .HasColumnType("integer");
+
+ b.Property("HttpServerHeader")
+ .HasMaxLength(200)
+ .IsUnicode(false)
+ .HasColumnType("character varying(200)");
+
+ b.Property("HttpStatusCode")
+ .HasColumnType("integer");
+
+ b.Property("IpAddress")
+ .IsRequired()
+ .HasMaxLength(45)
+ .IsUnicode(false)
+ .HasColumnType("character varying(45)");
+
+ b.Property("IsHomeKitCamera")
+ .HasColumnType("boolean");
+
+ b.Property("IsProcessed")
+ .HasColumnType("boolean");
+
+ b.Property("IsReachable")
+ .HasColumnType("boolean");
+
+ b.Property("MacAddress")
+ .HasMaxLength(17)
+ .IsUnicode(false)
+ .HasColumnType("character varying(17)");
+
+ b.Property("OnvifDeviceServiceUrl")
+ .HasMaxLength(500)
+ .IsUnicode(false)
+ .HasColumnType("character varying(500)");
+
+ b.Property("OnvifHardware")
+ .HasMaxLength(200)
+ .IsUnicode(false)
+ .HasColumnType("character varying(200)");
+
+ b.Property("OnvifName")
+ .HasMaxLength(200)
+ .IsUnicode(false)
+ .HasColumnType("character varying(200)");
+
+ b.Property("OnvifPort")
+ .HasColumnType("integer");
+
+ b.PrimitiveCollection("OpenPorts")
+ .IsRequired()
+ .IsUnicode(false)
+ .HasColumnType("integer[]");
+
+ b.Property("ProbedAt")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("timestamp with time zone")
+ .HasDefaultValueSql("NOW()");
+
+ b.Property("SiteId")
+ .HasColumnType("uuid");
+
+ b.Property("Vendor")
+ .HasMaxLength(100)
+ .IsUnicode(false)
+ .HasColumnType("character varying(100)");
+
+ b.HasKey("Id");
+
+ b.HasIndex("IpAddress");
+
+ b.HasIndex("IsProcessed");
+
+ b.HasIndex("SiteId");
+
+ b.ToTable("camera_discovery_results", (string)null);
+ });
+
+ modelBuilder.Entity("Heimdall.Domain.Entities.CameraEvent", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("uuid");
+
+ b.Property("AgentId")
+ .HasColumnType("uuid");
+
+ b.Property("CameraId")
+ .HasColumnType("uuid");
+
+ b.Property("Confidence")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("double precision")
+ .HasDefaultValue(0.0);
+
+ b.Property("CreatedAt")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("timestamp with time zone")
+ .HasDefaultValueSql("NOW()");
+
+ b.Property("Label")
+ .HasMaxLength(200)
+ .IsUnicode(false)
+ .HasColumnType("character varying(200)");
+
+ b.Property("MetadataJson")
+ .HasColumnType("jsonb");
+
+ b.Property("OccurredAt")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property("SnapshotThumbUrl")
+ .HasMaxLength(2000)
+ .IsUnicode(false)
+ .HasColumnType("character varying(2000)");
+
+ b.Property("SnapshotUrl")
+ .HasMaxLength(2000)
+ .IsUnicode(false)
+ .HasColumnType("character varying(2000)");
+
+ b.Property("Type")
+ .HasColumnType("integer");
+
+ b.Property("UpdatedAt")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("timestamp with time zone")
+ .HasDefaultValueSql("NOW()");
+
+ b.HasKey("Id");
+
+ b.HasIndex("OccurredAt");
+
+ b.HasIndex("CameraId", "OccurredAt")
+ .IsDescending(false, true);
+
+ b.HasIndex("CameraId", "Type");
+
+ b.ToTable("camera_events", (string)null);
+ });
+
+ modelBuilder.Entity("Heimdall.Domain.Entities.DiscoveredStreamUrl", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("uuid");
+
+ b.PrimitiveCollection("Codecs")
+ .IsRequired()
+ .IsUnicode(false)
+ .HasColumnType("text[]");
+
+ b.Property("DiscoveryResultId")
+ .HasColumnType("uuid");
+
+ b.Property("Height")
+ .HasColumnType("integer");
+
+ b.Property("IsAlive")
+ .HasColumnType("boolean");
+
+ b.Property("IsMainStream")
+ .HasColumnType("boolean");
+
+ b.Property("LatencyMs")
+ .HasColumnType("bigint");
+
+ b.Property("Protocol")
+ .IsRequired()
+ .HasMaxLength(20)
+ .IsUnicode(false)
+ .HasColumnType("character varying(20)");
+
+ b.Property("Url")
+ .IsRequired()
+ .HasMaxLength(2000)
+ .IsUnicode(false)
+ .HasColumnType("character varying(2000)");
+
+ b.Property("Width")
+ .HasColumnType("integer");
+
+ b.HasKey("Id");
+
+ b.HasIndex("DiscoveryResultId");
+
+ b.HasIndex("IsAlive");
+
+ b.HasIndex("IsMainStream");
+
+ b.ToTable("discovered_streams", (string)null);
+ });
+
+ modelBuilder.Entity("Heimdall.Domain.Entities.Group", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("uuid");
+
+ b.Property("CreatedAt")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("timestamp with time zone")
+ .HasDefaultValueSql("NOW()");
+
+ b.Property("DeletedAt")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property("Description")
+ .HasMaxLength(1000)
+ .HasColumnType("character varying(1000)");
+
+ b.Property("IsDeleted")
+ .HasColumnType("boolean");
+
+ b.Property("Name")
+ .IsRequired()
+ .HasMaxLength(200)
+ .HasColumnType("character varying(200)");
+
+ b.Property("UpdatedAt")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("timestamp with time zone")
+ .HasDefaultValueSql("NOW()");
+
+ b.HasKey("Id");
+
+ b.HasIndex("IsDeleted")
+ .HasFilter("\"IsDeleted\" = false");
+
+ b.HasIndex("Name");
+
+ b.ToTable("groups", (string)null);
+ });
+
+ modelBuilder.Entity("Heimdall.Domain.Entities.Site", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("uuid");
+
+ b.Property("Address")
+ .HasMaxLength(500)
+ .HasColumnType("character varying(500)");
+
+ b.Property("CreatedAt")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("timestamp with time zone")
+ .HasDefaultValueSql("NOW()");
+
+ b.Property("DeletedAt")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property("Enabled")
+ .HasColumnType("boolean");
+
+ b.Property("IsDeleted")
+ .HasColumnType("boolean");
+
+ b.Property("Name")
+ .IsRequired()
+ .HasMaxLength(200)
+ .HasColumnType("character varying(200)");
+
+ b.Property("RegistrationTokenHash")
+ .HasMaxLength(128)
+ .IsUnicode(false)
+ .HasColumnType("character varying(128)");
+
+ b.Property("Timezone")
+ .IsRequired()
+ .ValueGeneratedOnAdd()
+ .HasMaxLength(100)
+ .IsUnicode(false)
+ .HasColumnType("character varying(100)")
+ .HasDefaultValue("UTC");
+
+ b.Property("TokenExpiresAt")
+ .HasColumnType("timestamp with time zone");
+
+ b.Property("UpdatedAt")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("timestamp with time zone")
+ .HasDefaultValueSql("NOW()");
+
+ b.HasKey("Id");
+
+ b.HasIndex("IsDeleted")
+ .HasFilter("\"IsDeleted\" = false");
+
+ b.HasIndex("Name");
+
+ b.ToTable("sites", (string)null);
+ });
+
+ modelBuilder.Entity("Heimdall.Domain.Entities.UserGroup", b =>
+ {
+ b.Property("UserId")
+ .HasColumnType("uuid");
+
+ b.Property("GroupId")
+ .HasColumnType("uuid");
+
+ b.HasKey("UserId", "GroupId");
+
+ b.HasIndex("GroupId");
+
+ b.ToTable("user_groups", (string)null);
+ });
+
+ modelBuilder.Entity("Heimdall.Domain.Entities.UserSite", b =>
+ {
+ b.Property("UserId")
+ .HasColumnType("uuid");
+
+ b.Property("SiteId")
+ .HasColumnType("uuid");
+
+ b.HasKey("UserId", "SiteId");
+
+ b.HasIndex("SiteId");
+
+ b.ToTable("user_sites", (string)null);
+ });
+
+ modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("integer");
+
+ NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id"));
+
+ b.Property("ClaimType")
+ .HasColumnType("text");
+
+ b.Property("ClaimValue")
+ .HasColumnType("text");
+
+ b.Property("RoleId")
+ .HasColumnType("uuid");
+
+ b.HasKey("Id");
+
+ b.HasIndex("RoleId");
+
+ b.ToTable("role_claims", (string)null);
+ });
+
+ modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("integer");
+
+ NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id"));
+
+ b.Property("ClaimType")
+ .HasColumnType("text");
+
+ b.Property("ClaimValue")
+ .HasColumnType("text");
+
+ b.Property("UserId")
+ .HasColumnType("uuid");
+
+ b.HasKey("Id");
+
+ b.HasIndex("UserId");
+
+ b.ToTable("user_claims", (string)null);
+ });
+
+ modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b =>
+ {
+ b.Property("LoginProvider")
+ .HasColumnType("text");
+
+ b.Property("ProviderKey")
+ .HasColumnType("text");
+
+ b.Property("ProviderDisplayName")
+ .HasColumnType("text");
+
+ b.Property("UserId")
+ .HasColumnType("uuid");
+
+ b.HasKey("LoginProvider", "ProviderKey");
+
+ b.HasIndex("UserId");
+
+ b.ToTable("user_logins", (string)null);
+ });
+
+ modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b =>
+ {
+ b.Property("UserId")
+ .HasColumnType("uuid");
+
+ b.Property