Device reset: Device.ResetRequested is a one-shot flag claimed atomically with a single UPDATE, so a queued reset is delivered exactly once. GET api/telemetry/AddData answers it with the bare token RST and nothing else; subsequent requests resume the normal routine. Adds POST api/admin/devices/{id}/request-reset (audited) plus an admin panel button, pending badge and confirm dialog.
Postgres migrations: PostgresGreenHomeDbContext owns Data/Migrations/Postgres while the SqlServer set stays untouched. Registers one context per provider with the base type forwarded, replaces EnsureCreated() with Migrate() for both, adds a complete InitialPostgres migration and an incremental AddDeviceResetRequested for SqlServer, and adds design-time factories so dotnet ef does not have to boot the API host.
Timestamps: Postgres DateTime columns are now timestamp with time zone, because Npgsql rejects Kind=Utc values on a naive timestamp column, which broke every write path (auth, settings, posts, checklists, alerts, audit logs). Removes the SpecifyKind(Unspecified) workarounds, fixes a 3:30 offset where already-UTC filters were passed through ToLocalTime(), and makes DataCopy migrate instead of EnsureCreated while passing timestamps through verbatim.
Tests: Test/GreenHome.SelfCheck applies the Postgres migrations and asserts that a queued reset is consumed exactly once and that timestamps round-trip as Utc.
1684 lines
59 KiB
C#
1684 lines
59 KiB
C#
// <auto-generated />
|
|
using System;
|
|
using GreenHome.Infrastructure.Data;
|
|
using Microsoft.EntityFrameworkCore;
|
|
using Microsoft.EntityFrameworkCore.Infrastructure;
|
|
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
|
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
|
|
|
#nullable disable
|
|
|
|
namespace GreenHome.Infrastructure.Data.Migrations.Postgres
|
|
{
|
|
[DbContext(typeof(PostgresGreenHomeDbContext))]
|
|
partial class PostgresGreenHomeDbContextModelSnapshot : ModelSnapshot
|
|
{
|
|
protected override void BuildModel(ModelBuilder modelBuilder)
|
|
{
|
|
#pragma warning disable 612, 618
|
|
modelBuilder
|
|
.HasAnnotation("ProductVersion", "9.0.9")
|
|
.HasAnnotation("Relational:MaxIdentifierLength", 63);
|
|
|
|
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
|
|
|
|
modelBuilder.Entity("GreenHome.Domain.AIProfile", b =>
|
|
{
|
|
b.Property<int>("Id")
|
|
.ValueGeneratedOnAdd()
|
|
.HasColumnType("integer");
|
|
|
|
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
|
|
|
b.Property<string>("ApiKey")
|
|
.IsRequired()
|
|
.HasMaxLength(500)
|
|
.HasColumnType("character varying(2000)");
|
|
|
|
b.Property<string>("BalanceCurrency")
|
|
.HasMaxLength(10)
|
|
.HasColumnType("character varying(40)");
|
|
|
|
b.Property<DateTime?>("BalanceUpdatedAt")
|
|
.HasColumnType("timestamp with time zone");
|
|
|
|
b.Property<decimal?>("BalanceUsd")
|
|
.HasColumnType("decimal(18,6)");
|
|
|
|
b.Property<string>("BaseUrl")
|
|
.IsRequired()
|
|
.HasMaxLength(300)
|
|
.HasColumnType("character varying(1200)");
|
|
|
|
b.Property<decimal?>("CompletionPricePer1M")
|
|
.HasColumnType("decimal(18,6)");
|
|
|
|
b.Property<DateTime>("CreatedAt")
|
|
.HasColumnType("timestamp with time zone");
|
|
|
|
b.Property<bool>("IsActive")
|
|
.HasColumnType("boolean");
|
|
|
|
b.Property<int?>("MaxTokens")
|
|
.HasColumnType("integer");
|
|
|
|
b.Property<string>("Model")
|
|
.IsRequired()
|
|
.HasMaxLength(100)
|
|
.HasColumnType("character varying(400)");
|
|
|
|
b.Property<string>("Name")
|
|
.IsRequired()
|
|
.HasMaxLength(100)
|
|
.HasColumnType("character varying(400)");
|
|
|
|
b.Property<decimal?>("PromptPricePer1M")
|
|
.HasColumnType("decimal(18,6)");
|
|
|
|
b.Property<int>("Provider")
|
|
.HasColumnType("integer");
|
|
|
|
b.Property<double?>("Temperature")
|
|
.HasColumnType("double precision");
|
|
|
|
b.Property<DateTime>("UpdatedAt")
|
|
.HasColumnType("timestamp with time zone");
|
|
|
|
b.HasKey("Id");
|
|
|
|
b.HasIndex("IsActive");
|
|
|
|
b.ToTable("AIProfiles", (string)null);
|
|
});
|
|
|
|
modelBuilder.Entity("GreenHome.Domain.AIQuery", b =>
|
|
{
|
|
b.Property<int>("Id")
|
|
.ValueGeneratedOnAdd()
|
|
.HasColumnType("integer");
|
|
|
|
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
|
|
|
b.Property<string>("Answer")
|
|
.IsRequired()
|
|
.HasColumnType("text");
|
|
|
|
b.Property<int>("CompletionTokens")
|
|
.HasColumnType("integer");
|
|
|
|
b.Property<decimal>("CostUsd")
|
|
.HasColumnType("decimal(18,8)");
|
|
|
|
b.Property<DateTime>("CreatedAt")
|
|
.HasColumnType("timestamp with time zone");
|
|
|
|
b.Property<int?>("DeviceId")
|
|
.HasColumnType("integer");
|
|
|
|
b.Property<string>("Model")
|
|
.HasMaxLength(100)
|
|
.HasColumnType("character varying(400)");
|
|
|
|
b.Property<int?>("ProfileId")
|
|
.HasColumnType("integer");
|
|
|
|
b.Property<int>("PromptTokens")
|
|
.HasColumnType("integer");
|
|
|
|
b.Property<string>("Question")
|
|
.IsRequired()
|
|
.HasColumnType("text");
|
|
|
|
b.Property<long?>("ResponseTimeMs")
|
|
.HasColumnType("bigint");
|
|
|
|
b.Property<double?>("Temperature")
|
|
.HasColumnType("double precision");
|
|
|
|
b.Property<int>("TotalTokens")
|
|
.HasColumnType("integer");
|
|
|
|
b.Property<int?>("UserId")
|
|
.HasColumnType("integer");
|
|
|
|
b.HasKey("Id");
|
|
|
|
b.HasIndex("CreatedAt");
|
|
|
|
b.HasIndex("DeviceId");
|
|
|
|
b.HasIndex("ProfileId");
|
|
|
|
b.HasIndex("UserId");
|
|
|
|
b.ToTable("AIQueries", (string)null);
|
|
});
|
|
|
|
modelBuilder.Entity("GreenHome.Domain.AdminAuditLog", b =>
|
|
{
|
|
b.Property<int>("Id")
|
|
.ValueGeneratedOnAdd()
|
|
.HasColumnType("integer");
|
|
|
|
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
|
|
|
b.Property<string>("Action")
|
|
.IsRequired()
|
|
.HasMaxLength(100)
|
|
.HasColumnType("character varying(400)");
|
|
|
|
b.Property<int>("AdminUserId")
|
|
.HasColumnType("integer");
|
|
|
|
b.Property<DateTime>("At")
|
|
.HasColumnType("timestamp with time zone");
|
|
|
|
b.Property<string>("Details")
|
|
.IsRequired()
|
|
.HasMaxLength(2000)
|
|
.HasColumnType("character varying(8000)");
|
|
|
|
b.Property<string>("TargetId")
|
|
.IsRequired()
|
|
.HasMaxLength(100)
|
|
.HasColumnType("character varying(400)");
|
|
|
|
b.HasKey("Id");
|
|
|
|
b.HasIndex("AdminUserId");
|
|
|
|
b.HasIndex("At");
|
|
|
|
b.ToTable("AdminAuditLogs", (string)null);
|
|
});
|
|
|
|
modelBuilder.Entity("GreenHome.Domain.AlertCondition", b =>
|
|
{
|
|
b.Property<int>("Id")
|
|
.ValueGeneratedOnAdd()
|
|
.HasColumnType("integer");
|
|
|
|
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
|
|
|
b.Property<int>("CallCooldownMinutes")
|
|
.HasColumnType("integer");
|
|
|
|
b.Property<DateTime>("CreatedAt")
|
|
.HasColumnType("timestamp with time zone");
|
|
|
|
b.Property<int>("DeviceId")
|
|
.HasColumnType("integer");
|
|
|
|
b.Property<bool>("IsEnabled")
|
|
.HasColumnType("boolean");
|
|
|
|
b.Property<int>("NotificationType")
|
|
.HasColumnType("integer");
|
|
|
|
b.Property<int>("SmsCooldownMinutes")
|
|
.HasColumnType("integer");
|
|
|
|
b.Property<int>("TimeType")
|
|
.HasColumnType("integer");
|
|
|
|
b.Property<DateTime>("UpdatedAt")
|
|
.HasColumnType("timestamp with time zone");
|
|
|
|
b.HasKey("Id");
|
|
|
|
b.HasIndex("DeviceId");
|
|
|
|
b.ToTable("AlertConditions", (string)null);
|
|
});
|
|
|
|
modelBuilder.Entity("GreenHome.Domain.AlertLog", b =>
|
|
{
|
|
b.Property<int>("Id")
|
|
.ValueGeneratedOnAdd()
|
|
.HasColumnType("integer");
|
|
|
|
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
|
|
|
b.Property<int?>("AlertConditionId")
|
|
.HasColumnType("integer");
|
|
|
|
b.Property<int>("AlertType")
|
|
.HasColumnType("integer");
|
|
|
|
b.Property<int>("DeviceId")
|
|
.HasColumnType("integer");
|
|
|
|
b.Property<string>("ErrorMessage")
|
|
.HasMaxLength(2000)
|
|
.HasColumnType("character varying(8000)");
|
|
|
|
b.Property<string>("Message")
|
|
.IsRequired()
|
|
.HasMaxLength(1000)
|
|
.HasColumnType("character varying(4000)");
|
|
|
|
b.Property<int>("NotificationType")
|
|
.HasColumnType("integer");
|
|
|
|
b.Property<string>("PhoneNumber")
|
|
.IsRequired()
|
|
.HasMaxLength(20)
|
|
.HasColumnType("character varying(80)");
|
|
|
|
b.Property<long>("ProcessingTimeMs")
|
|
.HasColumnType("bigint");
|
|
|
|
b.Property<DateTime>("SentAt")
|
|
.HasColumnType("timestamp with time zone");
|
|
|
|
b.Property<int>("Status")
|
|
.HasColumnType("integer");
|
|
|
|
b.Property<int>("UserId")
|
|
.HasColumnType("integer");
|
|
|
|
b.HasKey("Id");
|
|
|
|
b.HasIndex("AlertConditionId");
|
|
|
|
b.HasIndex("AlertType");
|
|
|
|
b.HasIndex("Status");
|
|
|
|
b.HasIndex("DeviceId", "SentAt");
|
|
|
|
b.HasIndex("UserId", "SentAt");
|
|
|
|
b.ToTable("AlertLogs", (string)null);
|
|
});
|
|
|
|
modelBuilder.Entity("GreenHome.Domain.AlertNotification", b =>
|
|
{
|
|
b.Property<int>("Id")
|
|
.ValueGeneratedOnAdd()
|
|
.HasColumnType("integer");
|
|
|
|
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
|
|
|
b.Property<int?>("AlertConditionId")
|
|
.HasColumnType("integer");
|
|
|
|
b.Property<int>("DeviceId")
|
|
.HasColumnType("integer");
|
|
|
|
b.Property<string>("ErrorMessage")
|
|
.HasMaxLength(1000)
|
|
.HasColumnType("character varying(4000)");
|
|
|
|
b.Property<bool>("IsSent")
|
|
.HasColumnType("boolean");
|
|
|
|
b.Property<string>("Message")
|
|
.IsRequired()
|
|
.HasMaxLength(500)
|
|
.HasColumnType("character varying(2000)");
|
|
|
|
b.Property<string>("MessageOutboxIds")
|
|
.HasMaxLength(500)
|
|
.HasColumnType("character varying(2000)");
|
|
|
|
b.Property<int>("NotificationType")
|
|
.HasColumnType("integer");
|
|
|
|
b.Property<DateTime>("SentAt")
|
|
.HasColumnType("timestamp with time zone");
|
|
|
|
b.Property<int>("UserId")
|
|
.HasColumnType("integer");
|
|
|
|
b.HasKey("Id");
|
|
|
|
b.HasIndex("AlertConditionId");
|
|
|
|
b.HasIndex("UserId");
|
|
|
|
b.HasIndex("DeviceId", "UserId", "AlertConditionId", "SentAt");
|
|
|
|
b.ToTable("AlertNotifications", (string)null);
|
|
});
|
|
|
|
modelBuilder.Entity("GreenHome.Domain.AlertRule", b =>
|
|
{
|
|
b.Property<int>("Id")
|
|
.ValueGeneratedOnAdd()
|
|
.HasColumnType("integer");
|
|
|
|
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
|
|
|
b.Property<int>("AlertConditionId")
|
|
.HasColumnType("integer");
|
|
|
|
b.Property<int>("ComparisonType")
|
|
.HasColumnType("integer");
|
|
|
|
b.Property<int>("Order")
|
|
.HasColumnType("integer");
|
|
|
|
b.Property<int>("SensorType")
|
|
.HasColumnType("integer");
|
|
|
|
b.Property<decimal>("Value1")
|
|
.HasColumnType("decimal(18,2)");
|
|
|
|
b.Property<decimal?>("Value2")
|
|
.HasColumnType("decimal(18,2)");
|
|
|
|
b.HasKey("Id");
|
|
|
|
b.HasIndex("AlertConditionId");
|
|
|
|
b.ToTable("AlertRules", (string)null);
|
|
});
|
|
|
|
modelBuilder.Entity("GreenHome.Domain.Checklist", b =>
|
|
{
|
|
b.Property<int>("Id")
|
|
.ValueGeneratedOnAdd()
|
|
.HasColumnType("integer");
|
|
|
|
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
|
|
|
b.Property<DateTime>("CreatedAt")
|
|
.HasColumnType("timestamp with time zone");
|
|
|
|
b.Property<int>("CreatedByUserId")
|
|
.HasColumnType("integer");
|
|
|
|
b.Property<string>("Description")
|
|
.HasMaxLength(1000)
|
|
.HasColumnType("character varying(4000)");
|
|
|
|
b.Property<int>("DeviceId")
|
|
.HasColumnType("integer");
|
|
|
|
b.Property<bool>("IsActive")
|
|
.HasColumnType("boolean");
|
|
|
|
b.Property<string>("Title")
|
|
.IsRequired()
|
|
.HasMaxLength(200)
|
|
.HasColumnType("character varying(800)");
|
|
|
|
b.HasKey("Id");
|
|
|
|
b.HasIndex("CreatedByUserId");
|
|
|
|
b.HasIndex("DeviceId", "IsActive");
|
|
|
|
b.ToTable("Checklists", (string)null);
|
|
});
|
|
|
|
modelBuilder.Entity("GreenHome.Domain.ChecklistCompletion", b =>
|
|
{
|
|
b.Property<int>("Id")
|
|
.ValueGeneratedOnAdd()
|
|
.HasColumnType("integer");
|
|
|
|
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
|
|
|
b.Property<int>("ChecklistId")
|
|
.HasColumnType("integer");
|
|
|
|
b.Property<DateTime>("CompletedAt")
|
|
.HasColumnType("timestamp with time zone");
|
|
|
|
b.Property<int>("CompletedByUserId")
|
|
.HasColumnType("integer");
|
|
|
|
b.Property<string>("Notes")
|
|
.HasMaxLength(2000)
|
|
.HasColumnType("character varying(8000)");
|
|
|
|
b.Property<string>("PersianDate")
|
|
.IsRequired()
|
|
.HasMaxLength(10)
|
|
.HasColumnType("character varying(40)");
|
|
|
|
b.HasKey("Id");
|
|
|
|
b.HasIndex("CompletedByUserId");
|
|
|
|
b.HasIndex("ChecklistId", "PersianDate");
|
|
|
|
b.ToTable("ChecklistCompletions", (string)null);
|
|
});
|
|
|
|
modelBuilder.Entity("GreenHome.Domain.ChecklistItem", b =>
|
|
{
|
|
b.Property<int>("Id")
|
|
.ValueGeneratedOnAdd()
|
|
.HasColumnType("integer");
|
|
|
|
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
|
|
|
b.Property<int>("ChecklistId")
|
|
.HasColumnType("integer");
|
|
|
|
b.Property<string>("Description")
|
|
.HasMaxLength(1000)
|
|
.HasColumnType("character varying(4000)");
|
|
|
|
b.Property<bool>("IsRequired")
|
|
.HasColumnType("boolean");
|
|
|
|
b.Property<int>("Order")
|
|
.HasColumnType("integer");
|
|
|
|
b.Property<string>("Title")
|
|
.IsRequired()
|
|
.HasMaxLength(300)
|
|
.HasColumnType("character varying(1200)");
|
|
|
|
b.HasKey("Id");
|
|
|
|
b.HasIndex("ChecklistId", "Order");
|
|
|
|
b.ToTable("ChecklistItems", (string)null);
|
|
});
|
|
|
|
modelBuilder.Entity("GreenHome.Domain.ChecklistItemCompletion", b =>
|
|
{
|
|
b.Property<int>("Id")
|
|
.ValueGeneratedOnAdd()
|
|
.HasColumnType("integer");
|
|
|
|
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
|
|
|
b.Property<int>("ChecklistCompletionId")
|
|
.HasColumnType("integer");
|
|
|
|
b.Property<int>("ChecklistItemId")
|
|
.HasColumnType("integer");
|
|
|
|
b.Property<bool>("IsChecked")
|
|
.HasColumnType("boolean");
|
|
|
|
b.Property<string>("Note")
|
|
.HasMaxLength(500)
|
|
.HasColumnType("character varying(2000)");
|
|
|
|
b.HasKey("Id");
|
|
|
|
b.HasIndex("ChecklistCompletionId");
|
|
|
|
b.HasIndex("ChecklistItemId");
|
|
|
|
b.ToTable("ChecklistItemCompletions", (string)null);
|
|
});
|
|
|
|
modelBuilder.Entity("GreenHome.Domain.DailyReport", b =>
|
|
{
|
|
b.Property<int>("Id")
|
|
.ValueGeneratedOnAdd()
|
|
.HasColumnType("integer");
|
|
|
|
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
|
|
|
b.Property<string>("Analysis")
|
|
.IsRequired()
|
|
.HasColumnType("text");
|
|
|
|
b.Property<int>("CompletionTokens")
|
|
.HasColumnType("integer");
|
|
|
|
b.Property<DateTime>("CreatedAt")
|
|
.HasColumnType("timestamp with time zone");
|
|
|
|
b.Property<int>("DeviceId")
|
|
.HasColumnType("integer");
|
|
|
|
b.Property<string>("Model")
|
|
.HasMaxLength(100)
|
|
.HasColumnType("character varying(400)");
|
|
|
|
b.Property<string>("PersianDate")
|
|
.IsRequired()
|
|
.HasMaxLength(10)
|
|
.HasColumnType("character varying(40)");
|
|
|
|
b.Property<int>("PersianDay")
|
|
.HasColumnType("integer");
|
|
|
|
b.Property<int>("PersianMonth")
|
|
.HasColumnType("integer");
|
|
|
|
b.Property<int>("PersianYear")
|
|
.HasColumnType("integer");
|
|
|
|
b.Property<int>("PromptTokens")
|
|
.HasColumnType("integer");
|
|
|
|
b.Property<int>("RecordCount")
|
|
.HasColumnType("integer");
|
|
|
|
b.Property<long?>("ResponseTimeMs")
|
|
.HasColumnType("bigint");
|
|
|
|
b.Property<int>("SampledRecordCount")
|
|
.HasColumnType("integer");
|
|
|
|
b.Property<int>("TotalTokens")
|
|
.HasColumnType("integer");
|
|
|
|
b.HasKey("Id");
|
|
|
|
b.HasIndex("CreatedAt");
|
|
|
|
b.HasIndex("DeviceId", "PersianDate")
|
|
.IsUnique();
|
|
|
|
b.HasIndex("DeviceId", "PersianYear", "PersianMonth");
|
|
|
|
b.ToTable("DailyReports", (string)null);
|
|
});
|
|
|
|
modelBuilder.Entity("GreenHome.Domain.Device", b =>
|
|
{
|
|
b.Property<int>("Id")
|
|
.ValueGeneratedOnAdd()
|
|
.HasColumnType("integer");
|
|
|
|
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
|
|
|
b.Property<string>("DeviceName")
|
|
.IsRequired()
|
|
.HasMaxLength(10)
|
|
.HasColumnType("character varying(40)");
|
|
|
|
b.Property<string>("Location")
|
|
.IsRequired()
|
|
.HasMaxLength(250)
|
|
.HasColumnType("character varying(1000)");
|
|
|
|
b.Property<string>("NeshanLocation")
|
|
.IsRequired()
|
|
.HasMaxLength(80)
|
|
.HasColumnType("character varying(320)");
|
|
|
|
b.Property<bool>("ResetRequested")
|
|
.ValueGeneratedOnAdd()
|
|
.HasColumnType("boolean")
|
|
.HasDefaultValue(false);
|
|
|
|
b.Property<int>("UserId")
|
|
.HasColumnType("integer");
|
|
|
|
b.HasKey("Id");
|
|
|
|
b.HasIndex("UserId");
|
|
|
|
b.ToTable("Devices", (string)null);
|
|
});
|
|
|
|
modelBuilder.Entity("GreenHome.Domain.DevicePost", b =>
|
|
{
|
|
b.Property<int>("Id")
|
|
.ValueGeneratedOnAdd()
|
|
.HasColumnType("integer");
|
|
|
|
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
|
|
|
b.Property<int>("AuthorUserId")
|
|
.HasColumnType("integer");
|
|
|
|
b.Property<string>("Content")
|
|
.IsRequired()
|
|
.HasMaxLength(5000)
|
|
.HasColumnType("character varying(20000)");
|
|
|
|
b.Property<DateTime>("CreatedAt")
|
|
.HasColumnType("timestamp with time zone");
|
|
|
|
b.Property<int>("DeviceId")
|
|
.HasColumnType("integer");
|
|
|
|
b.Property<int>("PostType")
|
|
.HasColumnType("integer");
|
|
|
|
b.Property<DateTime?>("UpdatedAt")
|
|
.HasColumnType("timestamp with time zone");
|
|
|
|
b.Property<int?>("VoiceDurationSeconds")
|
|
.HasColumnType("integer");
|
|
|
|
b.Property<string>("VoiceFilePath")
|
|
.HasMaxLength(500)
|
|
.HasColumnType("character varying(2000)");
|
|
|
|
b.HasKey("Id");
|
|
|
|
b.HasIndex("AuthorUserId");
|
|
|
|
b.HasIndex("DeviceId", "CreatedAt");
|
|
|
|
b.ToTable("DevicePosts", (string)null);
|
|
});
|
|
|
|
modelBuilder.Entity("GreenHome.Domain.DevicePostImage", b =>
|
|
{
|
|
b.Property<int>("Id")
|
|
.ValueGeneratedOnAdd()
|
|
.HasColumnType("integer");
|
|
|
|
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
|
|
|
b.Property<string>("ContentType")
|
|
.IsRequired()
|
|
.HasMaxLength(100)
|
|
.HasColumnType("character varying(400)");
|
|
|
|
b.Property<int>("DevicePostId")
|
|
.HasColumnType("integer");
|
|
|
|
b.Property<string>("FileName")
|
|
.IsRequired()
|
|
.HasMaxLength(255)
|
|
.HasColumnType("character varying(1020)");
|
|
|
|
b.Property<string>("FilePath")
|
|
.IsRequired()
|
|
.HasMaxLength(500)
|
|
.HasColumnType("character varying(2000)");
|
|
|
|
b.Property<long>("FileSize")
|
|
.HasColumnType("bigint");
|
|
|
|
b.Property<DateTime>("UploadedAt")
|
|
.HasColumnType("timestamp with time zone");
|
|
|
|
b.HasKey("Id");
|
|
|
|
b.HasIndex("DevicePostId");
|
|
|
|
b.ToTable("DevicePostImages", (string)null);
|
|
});
|
|
|
|
modelBuilder.Entity("GreenHome.Domain.DeviceRelay", b =>
|
|
{
|
|
b.Property<int>("Id")
|
|
.ValueGeneratedOnAdd()
|
|
.HasColumnType("integer");
|
|
|
|
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
|
|
|
b.Property<DateTime>("CreatedAt")
|
|
.HasColumnType("timestamp with time zone");
|
|
|
|
b.Property<int>("DeviceSettingsId")
|
|
.HasColumnType("integer");
|
|
|
|
b.Property<bool>("IsEnabled")
|
|
.HasColumnType("boolean");
|
|
|
|
b.Property<string>("Name")
|
|
.IsRequired()
|
|
.HasMaxLength(100)
|
|
.HasColumnType("character varying(400)");
|
|
|
|
b.Property<int>("RelayIndex")
|
|
.HasColumnType("integer");
|
|
|
|
b.Property<int>("RelayKind")
|
|
.HasColumnType("integer");
|
|
|
|
b.Property<DateTime>("UpdatedAt")
|
|
.HasColumnType("timestamp with time zone");
|
|
|
|
b.HasKey("Id");
|
|
|
|
b.HasIndex("DeviceSettingsId", "RelayIndex")
|
|
.IsUnique();
|
|
|
|
b.ToTable("DeviceRelays", (string)null);
|
|
});
|
|
|
|
modelBuilder.Entity("GreenHome.Domain.DeviceSettings", b =>
|
|
{
|
|
b.Property<int>("Id")
|
|
.ValueGeneratedOnAdd()
|
|
.HasColumnType("integer");
|
|
|
|
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
|
|
|
b.Property<decimal?>("AreaSquareMeters")
|
|
.HasColumnType("decimal(18,2)");
|
|
|
|
b.Property<string>("City")
|
|
.IsRequired()
|
|
.HasMaxLength(100)
|
|
.HasColumnType("character varying(400)");
|
|
|
|
b.Property<DateTime>("CreatedAt")
|
|
.HasColumnType("timestamp with time zone");
|
|
|
|
b.Property<int>("DeviceId")
|
|
.HasColumnType("integer");
|
|
|
|
b.Property<int?>("DeviceId1")
|
|
.HasColumnType("integer");
|
|
|
|
b.Property<string>("DevicePhoneNumber")
|
|
.IsRequired()
|
|
.HasColumnType("text");
|
|
|
|
b.Property<decimal?>("Latitude")
|
|
.HasColumnType("decimal(9,6)");
|
|
|
|
b.Property<decimal?>("Longitude")
|
|
.HasColumnType("decimal(9,6)");
|
|
|
|
b.Property<int>("MinimumCallIntervalMinutes")
|
|
.ValueGeneratedOnAdd()
|
|
.HasColumnType("integer")
|
|
.HasDefaultValue(60);
|
|
|
|
b.Property<int>("MinimumSmsIntervalMinutes")
|
|
.ValueGeneratedOnAdd()
|
|
.HasColumnType("integer")
|
|
.HasDefaultValue(15);
|
|
|
|
b.Property<string>("ProductType")
|
|
.IsRequired()
|
|
.HasMaxLength(100)
|
|
.HasColumnType("character varying(400)");
|
|
|
|
b.Property<string>("Province")
|
|
.IsRequired()
|
|
.HasMaxLength(100)
|
|
.HasColumnType("character varying(400)");
|
|
|
|
b.Property<int>("RelayCount")
|
|
.ValueGeneratedOnAdd()
|
|
.HasColumnType("integer")
|
|
.HasDefaultValue(4);
|
|
|
|
b.Property<int?>("SimCardType")
|
|
.HasColumnType("integer");
|
|
|
|
b.Property<string>("SmsRecievers")
|
|
.IsRequired()
|
|
.HasMaxLength(120)
|
|
.HasColumnType("character varying(480)");
|
|
|
|
b.Property<string>("TokenCode")
|
|
.HasColumnType("text");
|
|
|
|
b.Property<DateTime?>("TokenExpiresAt")
|
|
.HasColumnType("timestamp with time zone");
|
|
|
|
b.Property<DateTime>("UpdatedAt")
|
|
.HasColumnType("timestamp with time zone");
|
|
|
|
b.Property<int>("UploadIntervalMin")
|
|
.HasColumnType("integer");
|
|
|
|
b.Property<string>("VerificationCode")
|
|
.HasColumnType("text");
|
|
|
|
b.HasKey("Id");
|
|
|
|
b.HasIndex("DeviceId")
|
|
.IsUnique();
|
|
|
|
b.HasIndex("DeviceId1");
|
|
|
|
b.ToTable("DeviceSettings", (string)null);
|
|
});
|
|
|
|
modelBuilder.Entity("GreenHome.Domain.DeviceUser", b =>
|
|
{
|
|
b.Property<int>("DeviceId")
|
|
.HasColumnType("integer");
|
|
|
|
b.Property<int>("UserId")
|
|
.HasColumnType("integer");
|
|
|
|
b.Property<string>("AvatarPath")
|
|
.HasMaxLength(500)
|
|
.HasColumnType("character varying(2000)");
|
|
|
|
b.Property<string>("Family")
|
|
.IsRequired()
|
|
.HasMaxLength(100)
|
|
.HasColumnType("character varying(400)");
|
|
|
|
b.Property<string>("Name")
|
|
.IsRequired()
|
|
.HasMaxLength(100)
|
|
.HasColumnType("character varying(400)");
|
|
|
|
b.Property<bool>("ReceiveAlerts")
|
|
.ValueGeneratedOnAdd()
|
|
.HasColumnType("boolean")
|
|
.HasDefaultValue(true);
|
|
|
|
b.Property<int>("Role")
|
|
.HasColumnType("integer");
|
|
|
|
b.HasKey("DeviceId", "UserId");
|
|
|
|
b.HasIndex("UserId");
|
|
|
|
b.ToTable("DeviceUsers", (string)null);
|
|
});
|
|
|
|
modelBuilder.Entity("GreenHome.Domain.PowerOutageLog", b =>
|
|
{
|
|
b.Property<int>("Id")
|
|
.ValueGeneratedOnAdd()
|
|
.HasColumnType("integer");
|
|
|
|
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
|
|
|
b.Property<byte>("CurrentPower")
|
|
.HasColumnType("smallint");
|
|
|
|
b.Property<int>("DeviceId")
|
|
.HasColumnType("integer");
|
|
|
|
b.Property<int>("EventType")
|
|
.HasColumnType("integer");
|
|
|
|
b.Property<string>("PersianDate")
|
|
.IsRequired()
|
|
.HasMaxLength(10)
|
|
.HasColumnType("character varying(40)");
|
|
|
|
b.Property<int>("PersianMonth")
|
|
.HasColumnType("integer");
|
|
|
|
b.Property<int>("PersianYear")
|
|
.HasColumnType("integer");
|
|
|
|
b.Property<byte>("PreviousPower")
|
|
.HasColumnType("smallint");
|
|
|
|
b.Property<DateTime>("ServerTimestampUtc")
|
|
.HasColumnType("timestamp with time zone");
|
|
|
|
b.Property<DateTime>("TimestampUtc")
|
|
.HasColumnType("timestamp with time zone");
|
|
|
|
b.HasKey("Id");
|
|
|
|
b.HasIndex("EventType");
|
|
|
|
b.HasIndex("DeviceId", "TimestampUtc");
|
|
|
|
b.HasIndex("DeviceId", "PersianYear", "PersianMonth");
|
|
|
|
b.ToTable("PowerOutageLogs", (string)null);
|
|
});
|
|
|
|
modelBuilder.Entity("GreenHome.Domain.RelayRuleCondition", b =>
|
|
{
|
|
b.Property<int>("Id")
|
|
.ValueGeneratedOnAdd()
|
|
.HasColumnType("integer");
|
|
|
|
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
|
|
|
b.Property<int?>("ComparisonType")
|
|
.HasColumnType("integer");
|
|
|
|
b.Property<int>("ConditionType")
|
|
.HasColumnType("integer");
|
|
|
|
b.Property<int?>("EndMinutes")
|
|
.HasColumnType("integer");
|
|
|
|
b.Property<int>("Order")
|
|
.HasColumnType("integer");
|
|
|
|
b.Property<int>("RelayRuleGroupId")
|
|
.HasColumnType("integer");
|
|
|
|
b.Property<int?>("SensorType")
|
|
.HasColumnType("integer");
|
|
|
|
b.Property<int?>("StartMinutes")
|
|
.HasColumnType("integer");
|
|
|
|
b.Property<decimal?>("Value1")
|
|
.HasColumnType("decimal(18,2)");
|
|
|
|
b.Property<decimal?>("Value2")
|
|
.HasColumnType("decimal(18,2)");
|
|
|
|
b.HasKey("Id");
|
|
|
|
b.HasIndex("RelayRuleGroupId");
|
|
|
|
b.ToTable("RelayRuleConditions", (string)null);
|
|
});
|
|
|
|
modelBuilder.Entity("GreenHome.Domain.RelayRuleGroup", b =>
|
|
{
|
|
b.Property<int>("Id")
|
|
.ValueGeneratedOnAdd()
|
|
.HasColumnType("integer");
|
|
|
|
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
|
|
|
b.Property<int>("Action")
|
|
.HasColumnType("integer");
|
|
|
|
b.Property<int>("DeviceRelayId")
|
|
.HasColumnType("integer");
|
|
|
|
b.Property<string>("Label")
|
|
.HasMaxLength(200)
|
|
.HasColumnType("character varying(800)");
|
|
|
|
b.Property<int>("Order")
|
|
.HasColumnType("integer");
|
|
|
|
b.HasKey("Id");
|
|
|
|
b.HasIndex("DeviceRelayId");
|
|
|
|
b.ToTable("RelayRuleGroups", (string)null);
|
|
});
|
|
|
|
modelBuilder.Entity("GreenHome.Domain.ReportImage", b =>
|
|
{
|
|
b.Property<int>("Id")
|
|
.ValueGeneratedOnAdd()
|
|
.HasColumnType("integer");
|
|
|
|
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
|
|
|
b.Property<string>("ContentType")
|
|
.IsRequired()
|
|
.HasMaxLength(100)
|
|
.HasColumnType("character varying(400)");
|
|
|
|
b.Property<string>("Description")
|
|
.HasMaxLength(500)
|
|
.HasColumnType("character varying(2000)");
|
|
|
|
b.Property<string>("FileName")
|
|
.IsRequired()
|
|
.HasMaxLength(255)
|
|
.HasColumnType("character varying(1020)");
|
|
|
|
b.Property<string>("FilePath")
|
|
.IsRequired()
|
|
.HasMaxLength(500)
|
|
.HasColumnType("character varying(2000)");
|
|
|
|
b.Property<long>("FileSize")
|
|
.HasColumnType("bigint");
|
|
|
|
b.Property<DateTime>("UploadedAt")
|
|
.HasColumnType("timestamp with time zone");
|
|
|
|
b.Property<int>("UserDailyReportId")
|
|
.HasColumnType("integer");
|
|
|
|
b.HasKey("Id");
|
|
|
|
b.HasIndex("UserDailyReportId");
|
|
|
|
b.ToTable("ReportImages", (string)null);
|
|
});
|
|
|
|
modelBuilder.Entity("GreenHome.Domain.TelemetryRecord", b =>
|
|
{
|
|
b.Property<int>("Id")
|
|
.ValueGeneratedOnAdd()
|
|
.HasColumnType("integer");
|
|
|
|
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
|
|
|
b.Property<decimal?>("BatteryPercent")
|
|
.HasColumnType("decimal(18,2)");
|
|
|
|
b.Property<decimal?>("BatteryVoltage")
|
|
.HasColumnType("decimal(18,2)");
|
|
|
|
b.Property<int>("DeviceId")
|
|
.HasColumnType("integer");
|
|
|
|
b.Property<int>("GasPPM")
|
|
.HasColumnType("integer");
|
|
|
|
b.Property<decimal>("HumidityPercent")
|
|
.HasColumnType("decimal(18,2)");
|
|
|
|
b.Property<decimal>("Lux")
|
|
.HasColumnType("decimal(18,2)");
|
|
|
|
b.Property<string>("PersianDate")
|
|
.IsRequired()
|
|
.HasMaxLength(10)
|
|
.HasColumnType("character varying(40)");
|
|
|
|
b.Property<int>("PersianMonth")
|
|
.HasColumnType("integer");
|
|
|
|
b.Property<int>("PersianYear")
|
|
.HasColumnType("integer");
|
|
|
|
b.Property<byte?>("Power")
|
|
.HasColumnType("smallint");
|
|
|
|
b.Property<string>("RelayStates")
|
|
.HasMaxLength(64)
|
|
.HasColumnType("character varying(256)");
|
|
|
|
b.Property<DateTime>("ServerTimestampUtc")
|
|
.HasColumnType("timestamp with time zone");
|
|
|
|
b.Property<decimal>("SoilPercent")
|
|
.HasColumnType("decimal(18,2)");
|
|
|
|
b.Property<decimal>("TemperatureC")
|
|
.HasColumnType("decimal(18,2)");
|
|
|
|
b.Property<DateTime>("TimestampUtc")
|
|
.HasColumnType("timestamp with time zone");
|
|
|
|
b.Property<decimal?>("Voltage")
|
|
.HasColumnType("decimal(18,2)");
|
|
|
|
b.HasKey("Id");
|
|
|
|
b.HasIndex("DeviceId", "ServerTimestampUtc");
|
|
|
|
b.HasIndex("DeviceId", "TimestampUtc");
|
|
|
|
b.HasIndex("DeviceId", "PersianYear", "PersianMonth");
|
|
|
|
b.ToTable("Telemetry", (string)null);
|
|
});
|
|
|
|
modelBuilder.Entity("GreenHome.Domain.UsageCounter", b =>
|
|
{
|
|
b.Property<int>("Id")
|
|
.ValueGeneratedOnAdd()
|
|
.HasColumnType("integer");
|
|
|
|
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
|
|
|
b.Property<int>("AiQueryCount")
|
|
.HasColumnType("integer");
|
|
|
|
b.Property<int>("AiTokenCount")
|
|
.HasColumnType("integer");
|
|
|
|
b.Property<DateOnly>("Date")
|
|
.HasColumnType("date");
|
|
|
|
b.Property<int>("SmsCount")
|
|
.HasColumnType("integer");
|
|
|
|
b.Property<int>("UserId")
|
|
.HasColumnType("integer");
|
|
|
|
b.Property<int>("VoiceCallCount")
|
|
.HasColumnType("integer");
|
|
|
|
b.HasKey("Id");
|
|
|
|
b.HasIndex("Date");
|
|
|
|
b.HasIndex("UserId", "Date")
|
|
.IsUnique();
|
|
|
|
b.ToTable("UsageCounters", (string)null);
|
|
});
|
|
|
|
modelBuilder.Entity("GreenHome.Domain.User", b =>
|
|
{
|
|
b.Property<int>("Id")
|
|
.ValueGeneratedOnAdd()
|
|
.HasColumnType("integer");
|
|
|
|
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
|
|
|
b.Property<DateTime>("CreatedAt")
|
|
.HasColumnType("timestamp with time zone");
|
|
|
|
b.Property<string>("Family")
|
|
.IsRequired()
|
|
.HasMaxLength(100)
|
|
.HasColumnType("character varying(400)");
|
|
|
|
b.Property<bool>("IsDisabled")
|
|
.HasColumnType("boolean");
|
|
|
|
b.Property<DateTime?>("LastLoginAt")
|
|
.HasColumnType("timestamp with time zone");
|
|
|
|
b.Property<string>("Mobile")
|
|
.IsRequired()
|
|
.HasMaxLength(11)
|
|
.HasColumnType("character varying(44)");
|
|
|
|
b.Property<string>("Name")
|
|
.IsRequired()
|
|
.HasMaxLength(100)
|
|
.HasColumnType("character varying(400)");
|
|
|
|
b.Property<int>("Role")
|
|
.HasColumnType("integer");
|
|
|
|
b.HasKey("Id");
|
|
|
|
b.HasIndex("Mobile")
|
|
.IsUnique();
|
|
|
|
b.ToTable("Users", (string)null);
|
|
});
|
|
|
|
modelBuilder.Entity("GreenHome.Domain.UserDailyReport", b =>
|
|
{
|
|
b.Property<int>("Id")
|
|
.ValueGeneratedOnAdd()
|
|
.HasColumnType("integer");
|
|
|
|
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
|
|
|
b.Property<DateTime>("CreatedAt")
|
|
.HasColumnType("timestamp with time zone");
|
|
|
|
b.Property<int>("DeviceId")
|
|
.HasColumnType("integer");
|
|
|
|
b.Property<string>("Notes")
|
|
.HasMaxLength(2000)
|
|
.HasColumnType("character varying(8000)");
|
|
|
|
b.Property<string>("Observations")
|
|
.IsRequired()
|
|
.HasColumnType("text");
|
|
|
|
b.Property<string>("Operations")
|
|
.IsRequired()
|
|
.HasColumnType("text");
|
|
|
|
b.Property<string>("PersianDate")
|
|
.IsRequired()
|
|
.HasMaxLength(10)
|
|
.HasColumnType("character varying(40)");
|
|
|
|
b.Property<int>("PersianDay")
|
|
.HasColumnType("integer");
|
|
|
|
b.Property<int>("PersianMonth")
|
|
.HasColumnType("integer");
|
|
|
|
b.Property<int>("PersianYear")
|
|
.HasColumnType("integer");
|
|
|
|
b.Property<string>("Title")
|
|
.IsRequired()
|
|
.HasMaxLength(200)
|
|
.HasColumnType("character varying(800)");
|
|
|
|
b.Property<DateTime>("UpdatedAt")
|
|
.HasColumnType("timestamp with time zone");
|
|
|
|
b.Property<int>("UserId")
|
|
.HasColumnType("integer");
|
|
|
|
b.HasKey("Id");
|
|
|
|
b.HasIndex("UserId");
|
|
|
|
b.HasIndex("DeviceId", "PersianDate");
|
|
|
|
b.HasIndex("DeviceId", "PersianYear", "PersianMonth");
|
|
|
|
b.ToTable("UserDailyReports", (string)null);
|
|
});
|
|
|
|
modelBuilder.Entity("GreenHome.Domain.VerificationCode", b =>
|
|
{
|
|
b.Property<int>("Id")
|
|
.ValueGeneratedOnAdd()
|
|
.HasColumnType("integer");
|
|
|
|
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
|
|
|
b.Property<string>("Code")
|
|
.IsRequired()
|
|
.HasMaxLength(4)
|
|
.HasColumnType("character varying(16)");
|
|
|
|
b.Property<DateTime>("CreatedAt")
|
|
.HasColumnType("timestamp with time zone");
|
|
|
|
b.Property<DateTime>("ExpiresAt")
|
|
.HasColumnType("timestamp with time zone");
|
|
|
|
b.Property<bool>("IsUsed")
|
|
.HasColumnType("boolean");
|
|
|
|
b.Property<string>("Mobile")
|
|
.IsRequired()
|
|
.HasMaxLength(11)
|
|
.HasColumnType("character varying(44)");
|
|
|
|
b.Property<DateTime?>("UsedAt")
|
|
.HasColumnType("timestamp with time zone");
|
|
|
|
b.HasKey("Id");
|
|
|
|
b.HasIndex("Mobile", "Code", "IsUsed");
|
|
|
|
b.ToTable("VerificationCodes", (string)null);
|
|
});
|
|
|
|
modelBuilder.Entity("GreenHome.Domain.AIQuery", b =>
|
|
{
|
|
b.HasOne("GreenHome.Domain.Device", "Device")
|
|
.WithMany()
|
|
.HasForeignKey("DeviceId")
|
|
.OnDelete(DeleteBehavior.SetNull);
|
|
|
|
b.HasOne("GreenHome.Domain.AIProfile", "Profile")
|
|
.WithMany()
|
|
.HasForeignKey("ProfileId")
|
|
.OnDelete(DeleteBehavior.SetNull);
|
|
|
|
b.HasOne("GreenHome.Domain.User", "User")
|
|
.WithMany()
|
|
.HasForeignKey("UserId")
|
|
.OnDelete(DeleteBehavior.SetNull);
|
|
|
|
b.Navigation("Device");
|
|
|
|
b.Navigation("Profile");
|
|
|
|
b.Navigation("User");
|
|
});
|
|
|
|
modelBuilder.Entity("GreenHome.Domain.AdminAuditLog", b =>
|
|
{
|
|
b.HasOne("GreenHome.Domain.User", "AdminUser")
|
|
.WithMany()
|
|
.HasForeignKey("AdminUserId")
|
|
.OnDelete(DeleteBehavior.Restrict)
|
|
.IsRequired();
|
|
|
|
b.Navigation("AdminUser");
|
|
});
|
|
|
|
modelBuilder.Entity("GreenHome.Domain.AlertCondition", b =>
|
|
{
|
|
b.HasOne("GreenHome.Domain.Device", "Device")
|
|
.WithMany()
|
|
.HasForeignKey("DeviceId")
|
|
.OnDelete(DeleteBehavior.Cascade)
|
|
.IsRequired();
|
|
|
|
b.Navigation("Device");
|
|
});
|
|
|
|
modelBuilder.Entity("GreenHome.Domain.AlertLog", b =>
|
|
{
|
|
b.HasOne("GreenHome.Domain.AlertCondition", "AlertCondition")
|
|
.WithMany()
|
|
.HasForeignKey("AlertConditionId")
|
|
.OnDelete(DeleteBehavior.SetNull);
|
|
|
|
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("AlertCondition");
|
|
|
|
b.Navigation("Device");
|
|
|
|
b.Navigation("User");
|
|
});
|
|
|
|
modelBuilder.Entity("GreenHome.Domain.AlertNotification", b =>
|
|
{
|
|
b.HasOne("GreenHome.Domain.AlertCondition", "AlertCondition")
|
|
.WithMany()
|
|
.HasForeignKey("AlertConditionId")
|
|
.OnDelete(DeleteBehavior.Restrict);
|
|
|
|
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("AlertCondition");
|
|
|
|
b.Navigation("Device");
|
|
|
|
b.Navigation("User");
|
|
});
|
|
|
|
modelBuilder.Entity("GreenHome.Domain.AlertRule", b =>
|
|
{
|
|
b.HasOne("GreenHome.Domain.AlertCondition", "AlertCondition")
|
|
.WithMany("Rules")
|
|
.HasForeignKey("AlertConditionId")
|
|
.OnDelete(DeleteBehavior.Cascade)
|
|
.IsRequired();
|
|
|
|
b.Navigation("AlertCondition");
|
|
});
|
|
|
|
modelBuilder.Entity("GreenHome.Domain.Checklist", b =>
|
|
{
|
|
b.HasOne("GreenHome.Domain.User", "CreatedByUser")
|
|
.WithMany()
|
|
.HasForeignKey("CreatedByUserId")
|
|
.OnDelete(DeleteBehavior.Restrict)
|
|
.IsRequired();
|
|
|
|
b.HasOne("GreenHome.Domain.Device", "Device")
|
|
.WithMany()
|
|
.HasForeignKey("DeviceId")
|
|
.OnDelete(DeleteBehavior.Cascade)
|
|
.IsRequired();
|
|
|
|
b.Navigation("CreatedByUser");
|
|
|
|
b.Navigation("Device");
|
|
});
|
|
|
|
modelBuilder.Entity("GreenHome.Domain.ChecklistCompletion", b =>
|
|
{
|
|
b.HasOne("GreenHome.Domain.Checklist", "Checklist")
|
|
.WithMany("Completions")
|
|
.HasForeignKey("ChecklistId")
|
|
.OnDelete(DeleteBehavior.Cascade)
|
|
.IsRequired();
|
|
|
|
b.HasOne("GreenHome.Domain.User", "CompletedByUser")
|
|
.WithMany()
|
|
.HasForeignKey("CompletedByUserId")
|
|
.OnDelete(DeleteBehavior.Restrict)
|
|
.IsRequired();
|
|
|
|
b.Navigation("Checklist");
|
|
|
|
b.Navigation("CompletedByUser");
|
|
});
|
|
|
|
modelBuilder.Entity("GreenHome.Domain.ChecklistItem", b =>
|
|
{
|
|
b.HasOne("GreenHome.Domain.Checklist", "Checklist")
|
|
.WithMany("Items")
|
|
.HasForeignKey("ChecklistId")
|
|
.OnDelete(DeleteBehavior.Cascade)
|
|
.IsRequired();
|
|
|
|
b.Navigation("Checklist");
|
|
});
|
|
|
|
modelBuilder.Entity("GreenHome.Domain.ChecklistItemCompletion", b =>
|
|
{
|
|
b.HasOne("GreenHome.Domain.ChecklistCompletion", "ChecklistCompletion")
|
|
.WithMany("ItemCompletions")
|
|
.HasForeignKey("ChecklistCompletionId")
|
|
.OnDelete(DeleteBehavior.Cascade)
|
|
.IsRequired();
|
|
|
|
b.HasOne("GreenHome.Domain.ChecklistItem", "ChecklistItem")
|
|
.WithMany()
|
|
.HasForeignKey("ChecklistItemId")
|
|
.OnDelete(DeleteBehavior.Restrict)
|
|
.IsRequired();
|
|
|
|
b.Navigation("ChecklistCompletion");
|
|
|
|
b.Navigation("ChecklistItem");
|
|
});
|
|
|
|
modelBuilder.Entity("GreenHome.Domain.DailyReport", b =>
|
|
{
|
|
b.HasOne("GreenHome.Domain.Device", "Device")
|
|
.WithMany()
|
|
.HasForeignKey("DeviceId")
|
|
.OnDelete(DeleteBehavior.Cascade)
|
|
.IsRequired();
|
|
|
|
b.Navigation("Device");
|
|
});
|
|
|
|
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.DevicePost", b =>
|
|
{
|
|
b.HasOne("GreenHome.Domain.User", "AuthorUser")
|
|
.WithMany()
|
|
.HasForeignKey("AuthorUserId")
|
|
.OnDelete(DeleteBehavior.Restrict)
|
|
.IsRequired();
|
|
|
|
b.HasOne("GreenHome.Domain.Device", "Device")
|
|
.WithMany()
|
|
.HasForeignKey("DeviceId")
|
|
.OnDelete(DeleteBehavior.Cascade)
|
|
.IsRequired();
|
|
|
|
b.Navigation("AuthorUser");
|
|
|
|
b.Navigation("Device");
|
|
});
|
|
|
|
modelBuilder.Entity("GreenHome.Domain.DevicePostImage", b =>
|
|
{
|
|
b.HasOne("GreenHome.Domain.DevicePost", "DevicePost")
|
|
.WithMany("Images")
|
|
.HasForeignKey("DevicePostId")
|
|
.OnDelete(DeleteBehavior.Cascade)
|
|
.IsRequired();
|
|
|
|
b.Navigation("DevicePost");
|
|
});
|
|
|
|
modelBuilder.Entity("GreenHome.Domain.DeviceRelay", b =>
|
|
{
|
|
b.HasOne("GreenHome.Domain.DeviceSettings", "DeviceSettings")
|
|
.WithMany("Relays")
|
|
.HasForeignKey("DeviceSettingsId")
|
|
.OnDelete(DeleteBehavior.Cascade)
|
|
.IsRequired();
|
|
|
|
b.Navigation("DeviceSettings");
|
|
});
|
|
|
|
modelBuilder.Entity("GreenHome.Domain.DeviceSettings", b =>
|
|
{
|
|
b.HasOne("GreenHome.Domain.Device", "Device")
|
|
.WithMany()
|
|
.HasForeignKey("DeviceId")
|
|
.OnDelete(DeleteBehavior.Cascade)
|
|
.IsRequired();
|
|
|
|
b.HasOne("GreenHome.Domain.Device", null)
|
|
.WithMany("DeviceSettings")
|
|
.HasForeignKey("DeviceId1");
|
|
|
|
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.PowerOutageLog", b =>
|
|
{
|
|
b.HasOne("GreenHome.Domain.Device", "Device")
|
|
.WithMany()
|
|
.HasForeignKey("DeviceId")
|
|
.OnDelete(DeleteBehavior.Cascade)
|
|
.IsRequired();
|
|
|
|
b.Navigation("Device");
|
|
});
|
|
|
|
modelBuilder.Entity("GreenHome.Domain.RelayRuleCondition", b =>
|
|
{
|
|
b.HasOne("GreenHome.Domain.RelayRuleGroup", "RelayRuleGroup")
|
|
.WithMany("Conditions")
|
|
.HasForeignKey("RelayRuleGroupId")
|
|
.OnDelete(DeleteBehavior.Cascade)
|
|
.IsRequired();
|
|
|
|
b.Navigation("RelayRuleGroup");
|
|
});
|
|
|
|
modelBuilder.Entity("GreenHome.Domain.RelayRuleGroup", b =>
|
|
{
|
|
b.HasOne("GreenHome.Domain.DeviceRelay", "DeviceRelay")
|
|
.WithMany("RuleGroups")
|
|
.HasForeignKey("DeviceRelayId")
|
|
.OnDelete(DeleteBehavior.Cascade)
|
|
.IsRequired();
|
|
|
|
b.Navigation("DeviceRelay");
|
|
});
|
|
|
|
modelBuilder.Entity("GreenHome.Domain.ReportImage", b =>
|
|
{
|
|
b.HasOne("GreenHome.Domain.UserDailyReport", "UserDailyReport")
|
|
.WithMany("Images")
|
|
.HasForeignKey("UserDailyReportId")
|
|
.OnDelete(DeleteBehavior.Cascade)
|
|
.IsRequired();
|
|
|
|
b.Navigation("UserDailyReport");
|
|
});
|
|
|
|
modelBuilder.Entity("GreenHome.Domain.UsageCounter", b =>
|
|
{
|
|
b.HasOne("GreenHome.Domain.User", "User")
|
|
.WithMany()
|
|
.HasForeignKey("UserId")
|
|
.OnDelete(DeleteBehavior.Cascade)
|
|
.IsRequired();
|
|
|
|
b.Navigation("User");
|
|
});
|
|
|
|
modelBuilder.Entity("GreenHome.Domain.UserDailyReport", b =>
|
|
{
|
|
b.HasOne("GreenHome.Domain.Device", "Device")
|
|
.WithMany()
|
|
.HasForeignKey("DeviceId")
|
|
.OnDelete(DeleteBehavior.Cascade)
|
|
.IsRequired();
|
|
|
|
b.HasOne("GreenHome.Domain.User", "User")
|
|
.WithMany()
|
|
.HasForeignKey("UserId")
|
|
.OnDelete(DeleteBehavior.Restrict)
|
|
.IsRequired();
|
|
|
|
b.Navigation("Device");
|
|
|
|
b.Navigation("User");
|
|
});
|
|
|
|
modelBuilder.Entity("GreenHome.Domain.AlertCondition", b =>
|
|
{
|
|
b.Navigation("Rules");
|
|
});
|
|
|
|
modelBuilder.Entity("GreenHome.Domain.Checklist", b =>
|
|
{
|
|
b.Navigation("Completions");
|
|
|
|
b.Navigation("Items");
|
|
});
|
|
|
|
modelBuilder.Entity("GreenHome.Domain.ChecklistCompletion", b =>
|
|
{
|
|
b.Navigation("ItemCompletions");
|
|
});
|
|
|
|
modelBuilder.Entity("GreenHome.Domain.Device", b =>
|
|
{
|
|
b.Navigation("DeviceSettings");
|
|
|
|
b.Navigation("DeviceUsers");
|
|
});
|
|
|
|
modelBuilder.Entity("GreenHome.Domain.DevicePost", b =>
|
|
{
|
|
b.Navigation("Images");
|
|
});
|
|
|
|
modelBuilder.Entity("GreenHome.Domain.DeviceRelay", b =>
|
|
{
|
|
b.Navigation("RuleGroups");
|
|
});
|
|
|
|
modelBuilder.Entity("GreenHome.Domain.DeviceSettings", b =>
|
|
{
|
|
b.Navigation("Relays");
|
|
});
|
|
|
|
modelBuilder.Entity("GreenHome.Domain.RelayRuleGroup", b =>
|
|
{
|
|
b.Navigation("Conditions");
|
|
});
|
|
|
|
modelBuilder.Entity("GreenHome.Domain.User", b =>
|
|
{
|
|
b.Navigation("DeviceUsers");
|
|
});
|
|
|
|
modelBuilder.Entity("GreenHome.Domain.UserDailyReport", b =>
|
|
{
|
|
b.Navigation("Images");
|
|
});
|
|
#pragma warning restore 612, 618
|
|
}
|
|
}
|
|
}
|