//
using System;
using GreenHome.Infrastructure;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
#nullable disable
namespace GreenHome.Infrastructure.Migrations
{
[DbContext(typeof(GreenHomeDbContext))]
partial class GreenHomeDbContextModelSnapshot : ModelSnapshot
{
protected override void BuildModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "9.0.9")
.HasAnnotation("Relational:MaxIdentifierLength", 128);
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
modelBuilder.Entity("GreenHome.Domain.AlertNotification", b =>
{
b.Property("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"));
b.Property("AlertType")
.IsRequired()
.HasMaxLength(50)
.HasColumnType("nvarchar(50)");
b.Property("DeviceId")
.HasColumnType("int");
b.Property("ErrorMessage")
.HasMaxLength(1000)
.HasColumnType("nvarchar(1000)");
b.Property("IsSent")
.HasColumnType("bit");
b.Property("Message")
.IsRequired()
.HasMaxLength(500)
.HasColumnType("nvarchar(500)");
b.Property("MessageOutboxIds")
.HasMaxLength(500)
.HasColumnType("nvarchar(500)");
b.Property("SentAt")
.HasColumnType("datetime2");
b.Property("UserId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("UserId");
b.HasIndex("DeviceId", "UserId", "AlertType", "SentAt");
b.ToTable("AlertNotifications", (string)null);
});
modelBuilder.Entity("GreenHome.Domain.Device", b =>
{
b.Property("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"));
b.Property("DeviceName")
.IsRequired()
.HasMaxLength(10)
.HasColumnType("nvarchar(10)");
b.Property("Location")
.IsRequired()
.HasMaxLength(250)
.HasColumnType("nvarchar(250)");
b.Property("NeshanLocation")
.IsRequired()
.HasMaxLength(80)
.HasColumnType("nvarchar(80)");
b.Property("UserId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("UserId");
b.ToTable("Devices", (string)null);
});
modelBuilder.Entity("GreenHome.Domain.DeviceSettings", b =>
{
b.Property("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"));
b.Property("CreatedAt")
.HasColumnType("datetime2");
b.Property("DangerMaxTemperature")
.HasColumnType("decimal(18,2)");
b.Property("DangerMinTemperature")
.HasColumnType("decimal(18,2)");
b.Property("DeviceId")
.HasColumnType("int");
b.Property("MaxGasPPM")
.HasColumnType("int");
b.Property("MaxHumidityPercent")
.HasColumnType("decimal(18,2)");
b.Property("MaxLux")
.HasColumnType("decimal(18,2)");
b.Property("MaxTemperature")
.HasColumnType("decimal(18,2)");
b.Property("MinGasPPM")
.HasColumnType("int");
b.Property("MinHumidityPercent")
.HasColumnType("decimal(18,2)");
b.Property("MinLux")
.HasColumnType("decimal(18,2)");
b.Property("MinTemperature")
.HasColumnType("decimal(18,2)");
b.Property("UpdatedAt")
.HasColumnType("datetime2");
b.HasKey("Id");
b.HasIndex("DeviceId")
.IsUnique();
b.ToTable("DeviceSettings", (string)null);
});
modelBuilder.Entity("GreenHome.Domain.DeviceUser", b =>
{
b.Property("DeviceId")
.HasColumnType("int");
b.Property("UserId")
.HasColumnType("int");
b.HasKey("DeviceId", "UserId");
b.HasIndex("UserId");
b.ToTable("DeviceUsers", (string)null);
});
modelBuilder.Entity("GreenHome.Domain.TelemetryRecord", b =>
{
b.Property("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"));
b.Property("DeviceId")
.HasColumnType("int");
b.Property("GasPPM")
.HasColumnType("int");
b.Property("HumidityPercent")
.HasColumnType("decimal(18,2)");
b.Property("Lux")
.HasColumnType("decimal(18,2)");
b.Property("PersianDate")
.IsRequired()
.HasMaxLength(10)
.HasColumnType("nvarchar(10)");
b.Property("PersianMonth")
.HasColumnType("int");
b.Property("PersianYear")
.HasColumnType("int");
b.Property("SoilPercent")
.HasColumnType("decimal(18,2)");
b.Property("TemperatureC")
.HasColumnType("decimal(18,2)");
b.Property("TimestampUtc")
.HasColumnType("datetime2");
b.HasKey("Id");
b.HasIndex("DeviceId", "TimestampUtc");
b.HasIndex("DeviceId", "PersianYear", "PersianMonth");
b.ToTable("Telemetry", (string)null);
});
modelBuilder.Entity("GreenHome.Domain.User", b =>
{
b.Property("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"));
b.Property("CreatedAt")
.HasColumnType("datetime2");
b.Property("Family")
.IsRequired()
.HasMaxLength(100)
.HasColumnType("nvarchar(100)");
b.Property("LastLoginAt")
.HasColumnType("datetime2");
b.Property("Mobile")
.IsRequired()
.HasMaxLength(11)
.HasColumnType("nvarchar(11)");
b.Property("Name")
.IsRequired()
.HasMaxLength(100)
.HasColumnType("nvarchar(100)");
b.Property("Role")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("Mobile")
.IsUnique();
b.ToTable("Users", (string)null);
});
modelBuilder.Entity("GreenHome.Domain.VerificationCode", b =>
{
b.Property("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"));
b.Property("Code")
.IsRequired()
.HasMaxLength(4)
.HasColumnType("nvarchar(4)");
b.Property("CreatedAt")
.HasColumnType("datetime2");
b.Property("ExpiresAt")
.HasColumnType("datetime2");
b.Property("IsUsed")
.HasColumnType("bit");
b.Property("Mobile")
.IsRequired()
.HasMaxLength(11)
.HasColumnType("nvarchar(11)");
b.Property("UsedAt")
.HasColumnType("datetime2");
b.HasKey("Id");
b.HasIndex("Mobile", "Code", "IsUsed");
b.ToTable("VerificationCodes", (string)null);
});
modelBuilder.Entity("GreenHome.Domain.AlertNotification", b =>
{
b.HasOne("GreenHome.Domain.Device", "Device")
.WithMany()
.HasForeignKey("DeviceId")
.OnDelete(DeleteBehavior.Restrict)
.IsRequired();
b.HasOne("GreenHome.Domain.User", "User")
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Restrict)
.IsRequired();
b.Navigation("Device");
b.Navigation("User");
});
modelBuilder.Entity("GreenHome.Domain.Device", b =>
{
b.HasOne("GreenHome.Domain.User", "User")
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Restrict)
.IsRequired();
b.Navigation("User");
});
modelBuilder.Entity("GreenHome.Domain.DeviceSettings", b =>
{
b.HasOne("GreenHome.Domain.Device", "Device")
.WithMany()
.HasForeignKey("DeviceId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Device");
});
modelBuilder.Entity("GreenHome.Domain.DeviceUser", b =>
{
b.HasOne("GreenHome.Domain.Device", "Device")
.WithMany("DeviceUsers")
.HasForeignKey("DeviceId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("GreenHome.Domain.User", "User")
.WithMany("DeviceUsers")
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Device");
b.Navigation("User");
});
modelBuilder.Entity("GreenHome.Domain.Device", b =>
{
b.Navigation("DeviceUsers");
});
modelBuilder.Entity("GreenHome.Domain.User", b =>
{
b.Navigation("DeviceUsers");
});
#pragma warning restore 612, 618
}
}
}