//
using System;
using IoTSharp.Data;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
namespace IoTSharp.Migrations
{
[DbContext(typeof(ApplicationDbContext))]
[Migration("20201024123604_AddDeviceStatus")]
partial class AddDeviceStatus
{
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn)
.HasAnnotation("ProductVersion", "3.1.9")
.HasAnnotation("Relational:MaxIdentifierLength", 63);
modelBuilder.Entity("IoTSharp.Data.AuditLog", b =>
{
b.Property("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property("ActionData")
.HasColumnType("jsonb");
b.Property("ActionName")
.HasColumnType("text");
b.Property("ActionResult")
.HasColumnType("jsonb");
b.Property("ActiveDateTime")
.HasColumnType("timestamp without time zone");
b.Property("CustomerId")
.HasColumnType("uuid");
b.Property("ObjectID")
.HasColumnType("uuid");
b.Property("ObjectName")
.HasColumnType("text");
b.Property("ObjectType")
.HasColumnType("integer");
b.Property("TenantId")
.HasColumnType("uuid");
b.Property("UserId")
.HasColumnType("text");
b.Property("UserName")
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("CustomerId");
b.HasIndex("TenantId");
b.ToTable("AuditLog");
});
modelBuilder.Entity("IoTSharp.Data.AuthorizedKey", b =>
{
b.Property("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property("AuthToken")
.HasColumnType("text");
b.Property("CustomerId")
.HasColumnType("uuid");
b.Property("Name")
.HasColumnType("text");
b.Property("TenantId")
.HasColumnType("uuid");
b.HasKey("Id");
b.HasIndex("CustomerId");
b.HasIndex("TenantId");
b.ToTable("AuthorizedKeys");
});
modelBuilder.Entity("IoTSharp.Data.Customer", b =>
{
b.Property("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property("Address")
.HasColumnType("text");
b.Property("City")
.HasColumnType("text");
b.Property("Country")
.HasColumnType("text");
b.Property("Email")
.HasColumnType("text");
b.Property("Name")
.HasColumnType("text");
b.Property("Phone")
.HasColumnType("text");
b.Property("Province")
.HasColumnType("text");
b.Property("Street")
.HasColumnType("text");
b.Property("TenantId")
.HasColumnType("uuid");
b.Property("ZipCode")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("TenantId");
b.ToTable("Customer");
});
modelBuilder.Entity("IoTSharp.Data.DataStorage", b =>
{
b.Property("Catalog")
.HasColumnType("integer");
b.Property("DeviceId")
.HasColumnType("uuid");
b.Property("KeyName")
.HasColumnType("text");
b.Property("DataSide")
.HasColumnType("integer");
b.Property("DateTime")
.HasColumnType("timestamp with time zone");
b.Property("Type")
.HasColumnType("integer");
b.Property("Value_Binary")
.HasColumnType("bytea");
b.Property("Value_Boolean")
.HasColumnType("boolean");
b.Property("Value_DateTime")
.HasColumnType("timestamp with time zone");
b.Property("Value_Double")
.HasColumnType("double precision");
b.Property("Value_Json")
.HasColumnType("jsonb");
b.Property("Value_Long")
.HasColumnType("bigint");
b.Property("Value_String")
.HasColumnType("text");
b.Property("Value_XML")
.HasColumnType("xml");
b.HasKey("Catalog", "DeviceId", "KeyName");
b.HasIndex("Catalog");
b.HasIndex("Catalog", "DeviceId");
b.ToTable("DataStorage");
b.HasDiscriminator("Catalog").HasValue(0);
});
modelBuilder.Entity("IoTSharp.Data.Device", b =>
{
b.Property("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property("AuthorizedKeyId")
.HasColumnType("uuid");
b.Property("CustomerId")
.HasColumnType("uuid");
b.Property("DeviceType")
.HasColumnType("integer");
b.Property("LastActive")
.HasColumnType("timestamp without time zone");
b.Property("Name")
.HasColumnType("text");
b.Property("Online")
.HasColumnType("boolean");
b.Property("OwnerId")
.HasColumnType("uuid");
b.Property("TenantId")
.HasColumnType("uuid");
b.Property("Timeout")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("AuthorizedKeyId");
b.HasIndex("CustomerId");
b.HasIndex("OwnerId");
b.HasIndex("TenantId");
b.ToTable("Device");
b.HasDiscriminator("DeviceType").HasValue(0);
});
modelBuilder.Entity("IoTSharp.Data.DeviceIdentity", b =>
{
b.Property("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property("DeviceId")
.HasColumnType("uuid");
b.Property("IdentityId")
.IsRequired()
.HasColumnType("text");
b.Property("IdentityType")
.HasColumnType("integer");
b.Property("IdentityValue")
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("DeviceId");
b.ToTable("DeviceIdentities");
});
modelBuilder.Entity("IoTSharp.Data.Relationship", b =>
{
b.Property("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property("CustomerId")
.HasColumnType("uuid");
b.Property("IdentityUserId")
.HasColumnType("text");
b.Property("TenantId")
.HasColumnType("uuid");
b.HasKey("Id");
b.HasIndex("CustomerId");
b.HasIndex("IdentityUserId");
b.HasIndex("TenantId");
b.ToTable("Relationship");
});
modelBuilder.Entity("IoTSharp.Data.RetainedMessage", b =>
{
b.Property("Id")
.HasColumnType("text");
b.Property("Payload")
.HasColumnType("bytea");
b.Property("QualityOfServiceLevel")
.HasColumnType("integer");
b.Property("Retain")
.HasColumnType("boolean");
b.Property("Topic")
.HasColumnType("text");
b.HasKey("Id");
b.ToTable("RetainedMessage");
});
modelBuilder.Entity("IoTSharp.Data.TelemetryData", b =>
{
b.Property("DeviceId")
.HasColumnType("uuid");
b.Property("KeyName")
.HasColumnType("text");
b.Property("DateTime")
.HasColumnType("timestamp with time zone");
b.Property("DataSide")
.HasColumnType("integer");
b.Property("Type")
.HasColumnType("integer");
b.Property("Value_Binary")
.HasColumnType("bytea");
b.Property("Value_Boolean")
.HasColumnType("boolean");
b.Property("Value_DateTime")
.HasColumnType("timestamp with time zone");
b.Property("Value_Double")
.HasColumnType("double precision");
b.Property("Value_Json")
.HasColumnType("jsonb");
b.Property("Value_Long")
.HasColumnType("bigint");
b.Property("Value_String")
.HasColumnType("text");
b.Property("Value_XML")
.HasColumnType("xml");
b.HasKey("DeviceId", "KeyName", "DateTime");
b.HasIndex("DeviceId");
b.HasIndex("KeyName");
b.HasIndex("DeviceId", "KeyName");
b.HasIndex("DeviceId", "KeyName", "DateTime");
b.ToTable("TelemetryData");
});
modelBuilder.Entity("IoTSharp.Data.Tenant", b =>
{
b.Property("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uuid");
b.Property("Address")
.HasColumnType("text");
b.Property("City")
.HasColumnType("text");
b.Property("Country")
.HasColumnType("text");
b.Property("EMail")
.HasColumnType("text");
b.Property("Name")
.HasColumnType("text");
b.Property("Phone")
.HasColumnType("text");
b.Property("Province")
.HasColumnType("text");
b.Property("Street")
.HasColumnType("text");
b.Property("ZipCode")
.HasColumnType("integer");
b.HasKey("Id");
b.ToTable("Tenant");
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRole", b =>
{
b.Property("Id")
.HasColumnType("text");
b.Property("ConcurrencyStamp")
.IsConcurrencyToken()
.HasColumnType("text");
b.Property("Name")
.HasColumnType("character varying(256)")
.HasMaxLength(256);
b.Property("NormalizedName")
.HasColumnType("character varying(256)")
.HasMaxLength(256);
b.HasKey("Id");
b.HasIndex("NormalizedName")
.IsUnique()
.HasName("RoleNameIndex");
b.ToTable("AspNetRoles");
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b =>
{
b.Property("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer")
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
b.Property("ClaimType")
.HasColumnType("text");
b.Property("ClaimValue")
.HasColumnType("text");
b.Property("RoleId")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("RoleId");
b.ToTable("AspNetRoleClaims");
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUser", b =>
{
b.Property("Id")
.HasColumnType("text");
b.Property("AccessFailedCount")
.HasColumnType("integer");
b.Property("ConcurrencyStamp")
.IsConcurrencyToken()
.HasColumnType("text");
b.Property("Email")
.HasColumnType("character varying(256)")
.HasMaxLength(256);
b.Property("EmailConfirmed")
.HasColumnType("boolean");
b.Property("LockoutEnabled")
.HasColumnType("boolean");
b.Property("LockoutEnd")
.HasColumnType("timestamp with time zone");
b.Property("NormalizedEmail")
.HasColumnType("character varying(256)")
.HasMaxLength(256);
b.Property("NormalizedUserName")
.HasColumnType("character varying(256)")
.HasMaxLength(256);
b.Property("PasswordHash")
.HasColumnType("text");
b.Property("PhoneNumber")
.HasColumnType("text");
b.Property("PhoneNumberConfirmed")
.HasColumnType("boolean");
b.Property("SecurityStamp")
.HasColumnType("text");
b.Property("TwoFactorEnabled")
.HasColumnType("boolean");
b.Property("UserName")
.HasColumnType("character varying(256)")
.HasMaxLength(256);
b.HasKey("Id");
b.HasIndex("NormalizedEmail")
.HasName("EmailIndex");
b.HasIndex("NormalizedUserName")
.IsUnique()
.HasName("UserNameIndex");
b.ToTable("AspNetUsers");
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b =>
{
b.Property("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer")
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
b.Property("ClaimType")
.HasColumnType("text");
b.Property("ClaimValue")
.HasColumnType("text");
b.Property("UserId")
.IsRequired()
.HasColumnType("text");
b.HasKey("Id");
b.HasIndex("UserId");
b.ToTable("AspNetUserClaims");
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b =>
{
b.Property("LoginProvider")
.HasColumnType("text");
b.Property("ProviderKey")
.HasColumnType("text");
b.Property("ProviderDisplayName")
.HasColumnType("text");
b.Property("UserId")
.IsRequired()
.HasColumnType("text");
b.HasKey("LoginProvider", "ProviderKey");
b.HasIndex("UserId");
b.ToTable("AspNetUserLogins");
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b =>
{
b.Property("UserId")
.HasColumnType("text");
b.Property("RoleId")
.HasColumnType("text");
b.HasKey("UserId", "RoleId");
b.HasIndex("RoleId");
b.ToTable("AspNetUserRoles");
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b =>
{
b.Property("UserId")
.HasColumnType("text");
b.Property("LoginProvider")
.HasColumnType("text");
b.Property("Name")
.HasColumnType("text");
b.Property("Value")
.HasColumnType("text");
b.HasKey("UserId", "LoginProvider", "Name");
b.ToTable("AspNetUserTokens");
});
modelBuilder.Entity("IoTSharp.Data.AttributeLatest", b =>
{
b.HasBaseType("IoTSharp.Data.DataStorage");
b.HasDiscriminator().HasValue(2);
});
modelBuilder.Entity("IoTSharp.Data.TelemetryLatest", b =>
{
b.HasBaseType("IoTSharp.Data.DataStorage");
b.HasDiscriminator().HasValue(4);
});
modelBuilder.Entity("IoTSharp.Data.Gateway", b =>
{
b.HasBaseType("IoTSharp.Data.Device");
b.HasDiscriminator().HasValue(1);
});
modelBuilder.Entity("IoTSharp.Data.AuditLog", b =>
{
b.HasOne("IoTSharp.Data.Customer", "Customer")
.WithMany()
.HasForeignKey("CustomerId");
b.HasOne("IoTSharp.Data.Tenant", "Tenant")
.WithMany()
.HasForeignKey("TenantId");
});
modelBuilder.Entity("IoTSharp.Data.AuthorizedKey", b =>
{
b.HasOne("IoTSharp.Data.Customer", "Customer")
.WithMany()
.HasForeignKey("CustomerId");
b.HasOne("IoTSharp.Data.Tenant", "Tenant")
.WithMany()
.HasForeignKey("TenantId");
});
modelBuilder.Entity("IoTSharp.Data.Customer", b =>
{
b.HasOne("IoTSharp.Data.Tenant", "Tenant")
.WithMany("Customers")
.HasForeignKey("TenantId");
});
modelBuilder.Entity("IoTSharp.Data.Device", b =>
{
b.HasOne("IoTSharp.Data.AuthorizedKey", null)
.WithMany("Devices")
.HasForeignKey("AuthorizedKeyId");
b.HasOne("IoTSharp.Data.Customer", "Customer")
.WithMany("Devices")
.HasForeignKey("CustomerId");
b.HasOne("IoTSharp.Data.Gateway", "Owner")
.WithMany("Children")
.HasForeignKey("OwnerId");
b.HasOne("IoTSharp.Data.Tenant", "Tenant")
.WithMany("Devices")
.HasForeignKey("TenantId");
});
modelBuilder.Entity("IoTSharp.Data.DeviceIdentity", b =>
{
b.HasOne("IoTSharp.Data.Device", "Device")
.WithMany()
.HasForeignKey("DeviceId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("IoTSharp.Data.Relationship", b =>
{
b.HasOne("IoTSharp.Data.Customer", "Customer")
.WithMany()
.HasForeignKey("CustomerId");
b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", "IdentityUser")
.WithMany()
.HasForeignKey("IdentityUserId");
b.HasOne("IoTSharp.Data.Tenant", "Tenant")
.WithMany()
.HasForeignKey("TenantId");
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b =>
{
b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole", null)
.WithMany()
.HasForeignKey("RoleId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b =>
{
b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", null)
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b =>
{
b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", null)
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b =>
{
b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole", null)
.WithMany()
.HasForeignKey("RoleId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", null)
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b =>
{
b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", null)
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
#pragma warning restore 612, 618
}
}
}