// 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("20260922120000_AddDeviceCommandsTable")] partial class AddDeviceCommandsTable { /// 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.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("ClassroomId") .IsRequired() .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("RawDeviceToken") .HasColumnType("text"); b.Property("TenantId") .IsRequired() .HasColumnType("text"); b.HasKey("Id"); 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("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.DeviceCredential", 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("InstallationId"); b.ToTable("DeviceCredentials"); }); 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("ClassroomId") .IsRequired() .HasMaxLength(50) .HasColumnType("character varying(50)"); b.Property("CreatedAt") .HasColumnType("timestamp with time zone"); b.Property("DurationSeconds") .HasColumnType("integer"); b.Property("ExpiresAt") .HasColumnType("timestamp with time zone"); 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("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.HasKey("Id"); b.HasIndex("DeviceId", "UpdatedAt") .IsDescending(false, true); b.HasIndex("DeviceId", "Status"); 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") .HasMaxLength(100) .HasColumnType("character varying(100)"); b.Property("CreatedAt") .HasColumnType("timestamp with time zone"); b.Property("DisplayName") .IsRequired() .HasMaxLength(100) .HasColumnType("character varying(100)"); b.Property("IsActive") .HasColumnType("boolean"); b.Property("PasswordHash") .IsRequired() .HasColumnType("text"); b.Property("Role") .IsRequired() .HasMaxLength(50) .HasColumnType("character varying(50)"); b.Property("TenantId") .IsRequired() .HasColumnType("text"); b.Property("Username") .IsRequired() .HasMaxLength(100) .HasColumnType("character varying(100)"); b.HasKey("Id"); 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.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 } } }