//
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("20260922130000_AddDeviceCommandDurationMs")]
partial class AddDeviceCommandDurationMs
{
///
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()
.HasMaxLength(100)
.HasColumnType("character varying(100)");
b.Property("UsedAt")
.HasColumnType("timestamp with time zone");
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("Id")
.HasMaxLength(50)
.HasColumnType("character varying(50)");
b.Property("DisplayName")
.IsRequired()
.HasMaxLength(100)
.HasColumnType("character varying(100)");
b.Property("TenantId")
.IsRequired()
.HasMaxLength(100)
.HasColumnType("character varying(100)");
b.HasKey("Id");
b.HasIndex("TenantId");
b.ToTable("Classrooms");
});
modelBuilder.Entity("ClassNotify.Server.Domain.Entities.Device", 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("CurrentIp")
.HasMaxLength(50)
.HasColumnType("character varying(50)");
b.Property("DeviceTokenHash")
.IsRequired()
.HasMaxLength(128)
.HasColumnType("character varying(128)");
b.Property("Hostname")
.HasMaxLength(100)
.HasColumnType("character varying(100)");
b.Property("InstallationId")
.HasMaxLength(100)
.HasColumnType("character varying(100)");
b.Property("LastHeartbeat")
.HasColumnType("timestamp with time zone");
b.Property("OnlineState")
.IsRequired()
.HasMaxLength(20)
.HasColumnType("character varying(20)");
b.Property("TenantId")
.IsRequired()
.HasMaxLength(100)
.HasColumnType("character varying(100)");
b.HasKey("Id");
b.HasIndex("ClassroomId");
b.HasIndex("DeviceTokenHash")
.IsUnique();
b.HasIndex("InstallationId");
b.HasIndex("TenantId");
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.DeviceCredential", b =>
{
b.Property("DeviceId")
.HasColumnType("text");
b.Property("CreatedAt")
.HasColumnType("timestamp with time zone");
b.Property("EncryptedToken")
.IsRequired()
.HasColumnType("text");
b.Property("LastRotatedAt")
.HasColumnType("timestamp with time zone");
b.Property("TenantId")
.IsRequired()
.HasColumnType("text");
b.HasKey("DeviceId");
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("character varying(100)");
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", "Status");
b.HasIndex("DeviceId", "UpdatedAt")
.IsDescending(false, true);
b.HasIndex("NotificationId", "DeviceId")
.IsUnique();
b.ToTable("NotificationReceipts");
});
modelBuilder.Entity("ClassNotify.Server.Domain.Entities.RateLimitAuditLog", b =>
{
b.Property("Id")
.HasColumnType("text");
b.Property("Action")
.IsRequired()
.HasColumnType("text");
b.Property("ClientIp")
.IsRequired()
.HasColumnType("text");
b.Property("Endpoint")
.IsRequired()
.HasColumnType("text");
b.Property("Reason")
.IsRequired()
.HasColumnType("text");
b.Property("TenantId")
.HasColumnType("text");
b.Property("Timestamp")
.HasColumnType("timestamp with time zone");
b.Property("UserId")
.HasColumnType("text");
b.HasKey("Id");
b.ToTable("RateLimitAuditLogs");
});
modelBuilder.Entity("ClassNotify.Server.Domain.Entities.Tenant", b =>
{
b.Property("Id")
.HasMaxLength(100)
.HasColumnType("character varying(100)");
b.Property("CreatedAt")
.HasColumnType("timestamp with time zone");
b.Property("Name")
.IsRequired()
.HasMaxLength(100)
.HasColumnType("character varying(100)");
b.Property("Plan")
.IsRequired()
.HasMaxLength(50)
.HasColumnType("character varying(50)");
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("FullName")
.IsRequired()
.HasMaxLength(100)
.HasColumnType("character varying(100)");
b.Property("PasswordHash")
.IsRequired()
.HasMaxLength(256)
.HasColumnType("character varying(256)");
b.Property("Role")
.IsRequired()
.HasMaxLength(50)
.HasColumnType("character varying(50)");
b.Property("TenantId")
.IsRequired()
.HasMaxLength(100)
.HasColumnType("character varying(100)");
b.Property("Username")
.IsRequired()
.HasMaxLength(50)
.HasColumnType("character varying(50)");
b.HasKey("Id");
b.HasIndex("TenantId", "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", null)
.WithMany("Classrooms")
.HasForeignKey("TenantId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("ClassNotify.Server.Domain.Entities.Device", b =>
{
b.HasOne("ClassNotify.Server.Domain.Entities.Classroom", "Classroom")
.WithMany("Devices")
.HasForeignKey("ClassroomId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("ClassNotify.Server.Domain.Entities.Tenant", "Tenant")
.WithMany("Devices")
.HasForeignKey("TenantId")
.OnDelete(DeleteBehavior.Cascade)
.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
}
}
}