// using System; using ClassNotify.Server.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 ClassNotify.Server.Data.Migrations { [DbContext(typeof(ClassNotifyDbContext))] [Migration("20260925141051_AddDeviceSupportBundle")] partial class AddDeviceSupportBundle { /// protected override void BuildTargetModel(ModelBuilder modelBuilder) { #pragma warning disable 612, 618 modelBuilder .HasAnnotation("ProductVersion", "8.0.0") .HasAnnotation("Relational:MaxIdentifierLength", 63); NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); modelBuilder.Entity("ClassNotify.Server.Domain.Entities.ActivationCode", b => { b.Property("Code") .HasMaxLength(50) .HasColumnType("character varying(50)"); b.Property("ClassroomId") .IsRequired() .HasMaxLength(50) .HasColumnType("character varying(50)"); b.Property("ExpiresAt") .HasColumnType("timestamp with time zone"); b.Property("InstallationId") .HasMaxLength(100) .HasColumnType("character varying(100)"); b.Property("IsUsed") .HasColumnType("boolean"); b.Property("TenantId") .IsRequired() .HasColumnType("text"); b.Property("UsedAt") .HasColumnType("timestamp with time zone"); b.Property("UsedByDeviceId") .HasColumnType("text"); b.HasKey("Code"); b.HasIndex("ClassroomId"); b.HasIndex("Code") .IsUnique(); b.HasIndex("InstallationId"); b.HasIndex("TenantId"); b.ToTable("ActivationCodes"); }); modelBuilder.Entity("ClassNotify.Server.Domain.Entities.AdminAuditEvent", b => { b.Property("Id") .HasColumnType("text"); b.Property("Action") .IsRequired() .HasColumnType("text"); b.Property("ActorRole") .IsRequired() .HasColumnType("text"); b.Property("ActorUsername") .IsRequired() .HasColumnType("text"); b.Property("Details") .HasColumnType("text"); b.Property("IpAddress") .HasColumnType("text"); b.Property("OccurredAt") .HasColumnType("timestamp with time zone"); b.Property("TargetId") .IsRequired() .HasColumnType("text"); b.Property("TargetType") .IsRequired() .HasColumnType("text"); b.HasKey("Id"); b.ToTable("AdminAuditEvents"); }); modelBuilder.Entity("ClassNotify.Server.Domain.Entities.Classroom", b => { b.Property("TenantId") .HasColumnType("text"); b.Property("Id") .HasColumnType("text"); b.Property("CreatedAt") .HasColumnType("timestamp with time zone"); b.Property("DisplayName") .IsRequired() .HasMaxLength(100) .HasColumnType("character varying(100)"); b.Property("Grade") .HasMaxLength(50) .HasColumnType("character varying(50)"); b.Property("RoomNumber") .HasMaxLength(50) .HasColumnType("character varying(50)"); b.HasKey("TenantId", "Id"); b.HasIndex("TenantId", "Id"); b.ToTable("Classrooms"); }); modelBuilder.Entity("ClassNotify.Server.Domain.Entities.Device", b => { b.Property("Id") .HasColumnType("text"); b.Property("Architecture") .HasColumnType("text"); b.Property("ClassroomId") .IsRequired() .HasColumnType("text"); b.Property("ClientVersion") .HasColumnType("text"); b.Property("CreatedAt") .HasColumnType("timestamp with time zone"); b.Property("DeviceTokenHash") .IsRequired() .HasColumnType("text"); b.Property("Hostname") .HasMaxLength(200) .HasColumnType("character varying(200)"); b.Property("InstallationId") .HasMaxLength(100) .HasColumnType("character varying(100)"); b.Property("IsActive") .HasColumnType("boolean"); b.Property("LastHeartbeatAt") .HasColumnType("timestamp with time zone"); b.Property("LastHeartbeatCorrelationId") .HasColumnType("text"); b.Property("OsVersion") .HasColumnType("text"); b.Property("ProtocolVersion") .HasColumnType("integer"); b.Property("RawDeviceToken") .HasColumnType("text"); b.Property("ServiceVersion") .HasColumnType("text"); b.Property("TenantId") .IsRequired() .HasColumnType("text"); b.HasKey("Id"); b.HasIndex("Id") .IsUnique(); b.HasIndex("InstallationId") .IsUnique() .HasFilter("\"InstallationId\" IS NOT NULL"); b.HasIndex("TenantId"); b.HasIndex("TenantId", "ClassroomId"); b.ToTable("Devices"); }); modelBuilder.Entity("ClassNotify.Server.Domain.Entities.DeviceCommand", b => { b.Property("Id") .HasMaxLength(100) .HasColumnType("character varying(100)"); b.Property("CommandType") .IsRequired() .HasMaxLength(50) .HasColumnType("character varying(50)"); b.Property("CompletedAt") .HasColumnType("timestamp with time zone"); b.Property("CreatedAt") .HasColumnType("timestamp with time zone"); b.Property("CreatedBy") .IsRequired() .HasMaxLength(100) .HasColumnType("character varying(100)"); b.Property("DeviceId") .IsRequired() .HasMaxLength(100) .HasColumnType("character varying(100)"); b.Property("DurationMs") .HasColumnType("bigint"); b.Property("ExpiresAt") .HasColumnType("timestamp with time zone"); b.Property("Parameters") .HasColumnType("text"); b.Property("ResultCode") .HasColumnType("integer"); b.Property("ResultMessage") .HasMaxLength(1000) .HasColumnType("character varying(1000)"); b.Property("StartedAt") .HasColumnType("timestamp with time zone"); b.Property("Status") .IsRequired() .HasMaxLength(50) .HasColumnType("character varying(50)"); b.Property("TenantId") .IsRequired() .HasMaxLength(100) .HasColumnType("character varying(100)"); b.HasKey("Id"); b.HasIndex("DeviceId", "Status"); b.HasIndex("Status", "ExpiresAt"); b.HasIndex("TenantId", "DeviceId", "CreatedAt") .IsDescending(false, false, true); b.ToTable("DeviceCommands"); }); modelBuilder.Entity("ClassNotify.Server.Domain.Entities.DeviceCredentialRecord", b => { b.Property("DeviceId") .HasColumnType("text"); b.Property("CreatedAt") .HasColumnType("timestamp with time zone"); b.Property("DeviceTokenHash") .IsRequired() .HasColumnType("text"); b.Property("EncryptedRecoverableToken") .IsRequired() .HasColumnType("text"); b.Property("InstallationId") .IsRequired() .HasMaxLength(100) .HasColumnType("character varying(100)"); b.Property("RotatedAt") .HasColumnType("timestamp with time zone"); b.HasKey("DeviceId"); b.HasIndex("DeviceId") .IsUnique(); b.HasIndex("InstallationId") .IsUnique(); b.ToTable("DeviceCredentials"); }); modelBuilder.Entity("ClassNotify.Server.Domain.Entities.DeviceSelfCheckBatch", b => { b.Property("Id") .HasMaxLength(100) .HasColumnType("character varying(100)"); b.Property("ClientRequestId") .IsRequired() .HasMaxLength(64) .HasColumnType("character varying(64)"); b.Property("CompletedAtUtc") .HasColumnType("timestamp with time zone"); b.Property("CorrelationId") .IsRequired() .HasMaxLength(32) .HasColumnType("character varying(32)"); b.Property("CreatedAtUtc") .HasColumnType("timestamp with time zone"); b.Property("CreatedByUserId") .IsRequired() .HasMaxLength(100) .HasColumnType("character varying(100)"); b.Property("DeadlineAtUtc") .HasColumnType("timestamp with time zone"); b.Property("Status") .IsRequired() .HasMaxLength(32) .HasColumnType("character varying(32)"); b.Property("TargetDeviceCount") .HasColumnType("integer"); b.Property("UpdatedAtUtc") .HasColumnType("timestamp with time zone"); b.HasKey("Id"); b.HasIndex("CreatedAtUtc"); b.HasIndex("CreatedByUserId", "ClientRequestId") .IsUnique(); b.ToTable("DeviceSelfCheckBatches"); }); modelBuilder.Entity("ClassNotify.Server.Domain.Entities.DeviceSelfCheckRun", b => { b.Property("Id") .HasMaxLength(100) .HasColumnType("character varying(100)"); b.Property("BatchId") .HasMaxLength(100) .HasColumnType("character varying(100)"); b.Property("CompletedAtUtc") .HasColumnType("timestamp with time zone"); b.Property("CorrelationId") .IsRequired() .HasMaxLength(32) .HasColumnType("character varying(32)"); b.Property("DeadlineAtUtc") .HasColumnType("timestamp with time zone"); b.Property("DeviceId") .IsRequired() .HasMaxLength(100) .HasColumnType("character varying(100)"); b.Property("DispatchAttemptCount") .HasColumnType("integer"); b.Property("DispatchedAtUtc") .HasColumnType("timestamp with time zone"); b.Property("OverallStatus") .HasMaxLength(32) .HasColumnType("character varying(32)"); b.Property("RequestedAtUtc") .HasColumnType("timestamp with time zone"); b.Property("RequestedByUserId") .IsRequired() .HasMaxLength(100) .HasColumnType("character varying(100)"); b.Property("ResultJson") .HasMaxLength(32768) .HasColumnType("character varying(32768)"); b.Property("RunState") .IsRequired() .ValueGeneratedOnAdd() .HasMaxLength(32) .HasColumnType("character varying(32)") .HasDefaultValue("PendingDispatch"); b.Property("Status") .IsRequired() .HasMaxLength(50) .HasColumnType("character varying(50)"); b.Property("TenantId") .IsRequired() .HasMaxLength(100) .HasColumnType("character varying(100)"); b.HasKey("Id"); b.HasIndex("CorrelationId"); b.HasIndex("BatchId", "DeviceId") .IsUnique() .HasFilter("\"BatchId\" IS NOT NULL"); b.HasIndex("BatchId", "OverallStatus"); b.HasIndex("BatchId", "RunState"); b.HasIndex("DeviceId", "RequestedAtUtc") .IsDescending(false, true); b.HasIndex("TenantId", "Status"); b.ToTable("DeviceSelfChecks"); }); modelBuilder.Entity("ClassNotify.Server.Domain.Entities.DeviceSupportBundle", b => { b.Property("Id") .HasMaxLength(100) .HasColumnType("character varying(100)"); b.Property("ClientRequestId") .IsRequired() .HasMaxLength(64) .HasColumnType("character varying(64)"); b.Property("CompletedAtUtc") .HasColumnType("timestamp with time zone"); b.Property("CorrelationId") .IsRequired() .HasMaxLength(32) .HasColumnType("character varying(32)"); b.Property("CreatedAtUtc") .HasColumnType("timestamp with time zone"); b.Property("DeadlineAtUtc") .HasColumnType("timestamp with time zone"); b.Property("DeviceId") .IsRequired() .HasMaxLength(100) .HasColumnType("character varying(100)"); b.Property("DispatchAttemptCount") .HasColumnType("integer"); b.Property("DispatchedAtUtc") .HasColumnType("timestamp with time zone"); b.Property("ErrorCode") .HasMaxLength(100) .HasColumnType("character varying(100)"); b.Property("ExpiresAtUtc") .HasColumnType("timestamp with time zone"); b.Property("LastDispatchAttemptAtUtc") .HasColumnType("timestamp with time zone"); b.Property("NextDispatchAttemptAtUtc") .HasColumnType("timestamp with time zone"); b.Property("RequestedByUserId") .IsRequired() .HasMaxLength(100) .HasColumnType("character varying(100)"); b.Property("Sha256") .HasMaxLength(64) .HasColumnType("character varying(64)"); b.Property("SizeBytes") .HasColumnType("bigint"); b.Property("Status") .IsRequired() .HasMaxLength(32) .HasColumnType("character varying(32)"); b.Property("StoragePath") .HasMaxLength(500) .HasColumnType("character varying(500)"); b.Property("TenantId") .IsRequired() .HasMaxLength(100) .HasColumnType("character varying(100)"); b.Property("UpdatedAtUtc") .HasColumnType("timestamp with time zone"); b.HasKey("Id"); b.HasIndex("CorrelationId"); b.HasIndex("DeviceId") .IsUnique() .HasDatabaseName("UX_DeviceSupportBundles_Device_Active") .HasFilter("\"Status\" IN ('PendingDispatch', 'Collecting')"); b.HasIndex("ExpiresAtUtc"); b.HasIndex("DeviceId", "CreatedAtUtc"); b.HasIndex("RequestedByUserId", "ClientRequestId") .IsUnique(); b.HasIndex("Status", "NextDispatchAttemptAtUtc"); b.HasIndex("TenantId", "CreatedAtUtc"); b.ToTable("DeviceSupportBundles"); }); modelBuilder.Entity("ClassNotify.Server.Domain.Entities.MigrationMarker", b => { b.Property("Id") .HasMaxLength(100) .HasColumnType("character varying(100)"); b.Property("Details") .HasColumnType("text"); b.Property("MigratedAt") .HasColumnType("timestamp with time zone"); b.HasKey("Id"); b.ToTable("MigrationMarkers"); }); modelBuilder.Entity("ClassNotify.Server.Domain.Entities.Notification", b => { b.Property("Id") .HasMaxLength(100) .HasColumnType("character varying(100)"); b.Property("BroadcastId") .HasColumnType("text"); b.Property("CancelledAt") .HasColumnType("timestamp with time zone"); b.Property("CancelledBy") .HasColumnType("text"); b.Property("ClassroomId") .IsRequired() .HasMaxLength(50) .HasColumnType("character varying(50)"); b.Property("CorrelationId") .IsRequired() .HasMaxLength(32) .HasColumnType("character varying(32)"); b.Property("CreatedAt") .HasColumnType("timestamp with time zone"); b.Property("DurationSeconds") .HasColumnType("integer"); b.Property("ExpiresAt") .HasColumnType("timestamp with time zone"); b.Property("IsCancelled") .HasColumnType("boolean"); b.Property("Message") .IsRequired() .HasColumnType("text"); b.Property("Priority") .IsRequired() .HasMaxLength(50) .HasColumnType("character varying(50)"); b.Property("SenderName") .IsRequired() .HasMaxLength(100) .HasColumnType("character varying(100)"); b.Property("SenderUserId") .HasColumnType("text"); b.Property("Shake") .HasColumnType("boolean"); b.Property("TenantId") .IsRequired() .HasColumnType("text"); b.Property("Title") .IsRequired() .HasMaxLength(200) .HasColumnType("character varying(200)"); b.Property("Voice") .HasColumnType("boolean"); b.HasKey("Id"); b.HasIndex("CorrelationId"); b.HasIndex("ClassroomId", "CreatedAt") .IsDescending(false, true); b.HasIndex("TenantId", "CreatedAt") .IsDescending(false, true); b.HasIndex("TenantId", "ClassroomId", "ExpiresAt"); b.ToTable("Notifications"); }); modelBuilder.Entity("ClassNotify.Server.Domain.Entities.NotificationReceipt", b => { b.Property("Id") .HasMaxLength(100) .HasColumnType("character varying(100)"); b.Property("AcknowledgedAt") .HasColumnType("timestamp with time zone"); b.Property("DeviceId") .IsRequired() .HasMaxLength(100) .HasColumnType("character varying(100)"); b.Property("DeviceReceivedAt") .HasColumnType("timestamp with time zone"); b.Property("DisplayedAt") .HasColumnType("timestamp with time zone"); b.Property("FailedAt") .HasColumnType("timestamp with time zone"); b.Property("FailureReason") .HasMaxLength(500) .HasColumnType("character varying(500)"); b.Property("NotificationId") .IsRequired() .HasMaxLength(100) .HasColumnType("character varying(100)"); b.Property("Status") .IsRequired() .HasMaxLength(50) .HasColumnType("character varying(50)"); b.Property("UpdatedAt") .HasColumnType("timestamp with time zone"); b.Property("VisualReceiptCapturedAt") .HasColumnType("timestamp with time zone"); b.Property("VisualReceiptExpiresAt") .HasColumnType("timestamp with time zone"); b.Property("VisualReceiptPath") .HasMaxLength(500) .HasColumnType("character varying(500)"); b.Property("VisualReceiptSha256") .HasMaxLength(64) .HasColumnType("character varying(64)"); b.Property("VisualReceiptSizeBytes") .HasColumnType("bigint"); b.Property("VisualReceiptState") .IsRequired() .ValueGeneratedOnAdd() .HasMaxLength(32) .HasColumnType("character varying(32)") .HasDefaultValue("None"); b.HasKey("Id"); b.HasIndex("VisualReceiptExpiresAt"); b.HasIndex("DeviceId", "Status"); b.HasIndex("DeviceId", "UpdatedAt") .IsDescending(false, true); b.HasIndex("NotificationId", "DeviceId") .IsUnique(); b.ToTable("NotificationReceipts"); }); modelBuilder.Entity("ClassNotify.Server.Domain.Entities.Tenant", b => { b.Property("Id") .HasColumnType("text"); b.Property("CreatedAt") .HasColumnType("timestamp with time zone"); b.Property("IsActive") .HasColumnType("boolean"); b.Property("Name") .IsRequired() .HasMaxLength(200) .HasColumnType("character varying(200)"); b.HasKey("Id"); b.ToTable("Tenants"); }); modelBuilder.Entity("ClassNotify.Server.Domain.Entities.User", b => { b.Property("Id") .HasColumnType("text"); b.Property("CreatedAt") .HasColumnType("timestamp with time zone"); b.Property("FullName") .IsRequired() .HasMaxLength(100) .HasColumnType("character varying(100)"); b.Property("IsLocked") .HasColumnType("boolean"); b.Property("LastLoginAt") .HasColumnType("timestamp with time zone"); b.Property("PasswordHash") .IsRequired() .HasColumnType("text"); b.Property("Role") .IsRequired() .HasMaxLength(50) .HasColumnType("character varying(50)"); b.Property("TenantId") .IsRequired() .HasColumnType("text"); b.Property("TokenVersion") .HasColumnType("integer"); b.Property("Username") .IsRequired() .HasMaxLength(100) .HasColumnType("character varying(100)"); b.HasKey("Id"); b.HasIndex("TenantId"); b.HasIndex("Username") .IsUnique(); b.ToTable("Users"); }); modelBuilder.Entity("ClassNotify.Server.Domain.Entities.ActivationCode", b => { b.HasOne("ClassNotify.Server.Domain.Entities.Tenant", "Tenant") .WithMany("ActivationCodes") .HasForeignKey("TenantId") .OnDelete(DeleteBehavior.Restrict) .IsRequired(); b.Navigation("Tenant"); }); modelBuilder.Entity("ClassNotify.Server.Domain.Entities.Classroom", b => { b.HasOne("ClassNotify.Server.Domain.Entities.Tenant", "Tenant") .WithMany("Classrooms") .HasForeignKey("TenantId") .OnDelete(DeleteBehavior.Cascade) .IsRequired(); b.Navigation("Tenant"); }); modelBuilder.Entity("ClassNotify.Server.Domain.Entities.Device", b => { b.HasOne("ClassNotify.Server.Domain.Entities.Tenant", "Tenant") .WithMany("Devices") .HasForeignKey("TenantId") .OnDelete(DeleteBehavior.Restrict) .IsRequired(); b.HasOne("ClassNotify.Server.Domain.Entities.Classroom", "Classroom") .WithMany("Devices") .HasForeignKey("TenantId", "ClassroomId") .OnDelete(DeleteBehavior.Restrict) .IsRequired(); b.Navigation("Classroom"); b.Navigation("Tenant"); }); modelBuilder.Entity("ClassNotify.Server.Domain.Entities.DeviceCommand", b => { b.HasOne("ClassNotify.Server.Domain.Entities.Device", "Device") .WithMany() .HasForeignKey("DeviceId") .OnDelete(DeleteBehavior.Cascade) .IsRequired(); b.HasOne("ClassNotify.Server.Domain.Entities.Tenant", "Tenant") .WithMany() .HasForeignKey("TenantId") .OnDelete(DeleteBehavior.Cascade) .IsRequired(); b.Navigation("Device"); b.Navigation("Tenant"); }); modelBuilder.Entity("ClassNotify.Server.Domain.Entities.DeviceSelfCheckRun", b => { b.HasOne("ClassNotify.Server.Domain.Entities.DeviceSelfCheckBatch", "Batch") .WithMany() .HasForeignKey("BatchId") .OnDelete(DeleteBehavior.Restrict); b.HasOne("ClassNotify.Server.Domain.Entities.Device", "Device") .WithMany() .HasForeignKey("DeviceId") .OnDelete(DeleteBehavior.Cascade) .IsRequired(); b.HasOne("ClassNotify.Server.Domain.Entities.Tenant", "Tenant") .WithMany() .HasForeignKey("TenantId") .OnDelete(DeleteBehavior.Cascade) .IsRequired(); b.Navigation("Batch"); b.Navigation("Device"); b.Navigation("Tenant"); }); modelBuilder.Entity("ClassNotify.Server.Domain.Entities.DeviceSupportBundle", b => { b.HasOne("ClassNotify.Server.Domain.Entities.Device", "Device") .WithMany() .HasForeignKey("DeviceId") .OnDelete(DeleteBehavior.Cascade) .IsRequired(); b.HasOne("ClassNotify.Server.Domain.Entities.Tenant", "Tenant") .WithMany() .HasForeignKey("TenantId") .OnDelete(DeleteBehavior.Cascade) .IsRequired(); b.Navigation("Device"); b.Navigation("Tenant"); }); modelBuilder.Entity("ClassNotify.Server.Domain.Entities.Notification", b => { b.HasOne("ClassNotify.Server.Domain.Entities.Tenant", "Tenant") .WithMany("Notifications") .HasForeignKey("TenantId") .OnDelete(DeleteBehavior.Cascade) .IsRequired(); b.Navigation("Tenant"); }); modelBuilder.Entity("ClassNotify.Server.Domain.Entities.NotificationReceipt", b => { b.HasOne("ClassNotify.Server.Domain.Entities.Device", "Device") .WithMany("Receipts") .HasForeignKey("DeviceId") .OnDelete(DeleteBehavior.Cascade) .IsRequired(); b.HasOne("ClassNotify.Server.Domain.Entities.Notification", "Notification") .WithMany("Receipts") .HasForeignKey("NotificationId") .OnDelete(DeleteBehavior.Cascade) .IsRequired(); b.Navigation("Device"); b.Navigation("Notification"); }); modelBuilder.Entity("ClassNotify.Server.Domain.Entities.User", b => { b.HasOne("ClassNotify.Server.Domain.Entities.Tenant", "Tenant") .WithMany("Users") .HasForeignKey("TenantId") .OnDelete(DeleteBehavior.Restrict) .IsRequired(); b.Navigation("Tenant"); }); modelBuilder.Entity("ClassNotify.Server.Domain.Entities.Classroom", b => { b.Navigation("Devices"); }); modelBuilder.Entity("ClassNotify.Server.Domain.Entities.Device", b => { b.Navigation("Receipts"); }); modelBuilder.Entity("ClassNotify.Server.Domain.Entities.Notification", b => { b.Navigation("Receipts"); }); modelBuilder.Entity("ClassNotify.Server.Domain.Entities.Tenant", b => { b.Navigation("ActivationCodes"); b.Navigation("Classrooms"); b.Navigation("Devices"); b.Navigation("Notifications"); b.Navigation("Users"); }); #pragma warning restore 612, 618 } } }