Generator Changes at 10/13/2025 8:08:52 AM

This commit is contained in:
MeysamMoghaddam
2025-10-13 08:19:47 +03:30
parent afad9b62be
commit f7da86ec02
41 changed files with 869 additions and 5 deletions

View File

@@ -41,10 +41,10 @@ public class ApplicationDbContext : DbContext, IApplicationDbContext
}
public DbSet<UserAddress> UserAddresss => Set<UserAddress>();
public DbSet<Package> Packages => Set<Package>();
public DbSet<UserOrder> UserOrders => Set<UserOrder>();
public DbSet<Role> Roles => Set<Role>();
public DbSet<UserRole> UserRoles => Set<UserRole>();
public DbSet<OtpToken> OtpTokens => Set<OtpToken>();
public DbSet<UserOrder> UserOrders => Set<UserOrder>();
public DbSet<User> Users => Set<User>();
}

View File

@@ -27,5 +27,9 @@ public class UserConfiguration : IEntityTypeConfiguration<User>
builder.Property(entity => entity.MobileVerifiedAt).IsRequired(false);
builder.Property(entity => entity.IsRulesAccepted).IsRequired(true);
builder.Property(entity => entity.RulesAcceptedAt).IsRequired(false);
builder.Property(entity => entity.EmailNotifications).IsRequired(true);
builder.Property(entity => entity.SmsNotifications).IsRequired(true);
builder.Property(entity => entity.PushNotifications).IsRequired(true);
builder.Property(entity => entity.BirthDate).IsRequired(false);
}
}

View File

@@ -26,5 +26,11 @@ public class UserOrderConfiguration : IEntityTypeConfiguration<UserOrder>
.WithMany(entity => entity.UserOrders)
.HasForeignKey(entity => entity.UserId)
.IsRequired(true);
builder
.HasOne(entity => entity.UserAddress)
.WithMany(entity => entity.UserOrders)
.HasForeignKey(entity => entity.UserAddressId)
.OnDelete(deleteBehavior: DeleteBehavior.Restrict)
.IsRequired(true);
}
}

View File

@@ -0,0 +1,472 @@
// <auto-generated />
using System;
using CMSMicroservice.Infrastructure.Persistence;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
#nullable disable
namespace CMSMicroservice.Infrastructure.Persistence.Migrations
{
[DbContext(typeof(ApplicationDbContext))]
[Migration("20251013044349_u04")]
partial class u04
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasDefaultSchema("CMS")
.HasAnnotation("ProductVersion", "7.0.0")
.HasAnnotation("Relational:MaxIdentifierLength", 128);
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
modelBuilder.Entity("CMSMicroservice.Domain.Entities.OtpToken", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("bigint");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<long>("Id"));
b.Property<int>("Attempts")
.HasColumnType("int");
b.Property<string>("CodeHash")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<DateTime>("Created")
.HasColumnType("datetime2");
b.Property<string>("CreatedBy")
.HasColumnType("nvarchar(max)");
b.Property<DateTime>("ExpiresAt")
.HasColumnType("datetime2");
b.Property<bool>("IsDeleted")
.HasColumnType("bit");
b.Property<bool>("IsUsed")
.HasColumnType("bit");
b.Property<DateTime?>("LastModified")
.HasColumnType("datetime2");
b.Property<string>("LastModifiedBy")
.HasColumnType("nvarchar(max)");
b.Property<string>("Mobile")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("Purpose")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.ToTable("OtpTokens", "CMS");
});
modelBuilder.Entity("CMSMicroservice.Domain.Entities.Package", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("bigint");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<long>("Id"));
b.Property<DateTime>("Created")
.HasColumnType("datetime2");
b.Property<string>("CreatedBy")
.HasColumnType("nvarchar(max)");
b.Property<string>("Description")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("ImagePath")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<bool>("IsDeleted")
.HasColumnType("bit");
b.Property<DateTime?>("LastModified")
.HasColumnType("datetime2");
b.Property<string>("LastModifiedBy")
.HasColumnType("nvarchar(max)");
b.Property<long>("Price")
.HasColumnType("bigint");
b.Property<string>("Title")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.ToTable("Packages", "CMS");
});
modelBuilder.Entity("CMSMicroservice.Domain.Entities.Role", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("bigint");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<long>("Id"));
b.Property<DateTime>("Created")
.HasColumnType("datetime2");
b.Property<string>("CreatedBy")
.HasColumnType("nvarchar(max)");
b.Property<bool>("IsDeleted")
.HasColumnType("bit");
b.Property<DateTime?>("LastModified")
.HasColumnType("datetime2");
b.Property<string>("LastModifiedBy")
.HasColumnType("nvarchar(max)");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("Title")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.ToTable("Roles", "CMS");
});
modelBuilder.Entity("CMSMicroservice.Domain.Entities.User", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("bigint");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<long>("Id"));
b.Property<string>("AvatarPath")
.HasColumnType("nvarchar(max)");
b.Property<DateTime?>("BirthDate")
.HasColumnType("datetime2");
b.Property<DateTime>("Created")
.HasColumnType("datetime2");
b.Property<string>("CreatedBy")
.HasColumnType("nvarchar(max)");
b.Property<bool>("EmailNotifications")
.HasColumnType("bit");
b.Property<string>("FirstName")
.HasColumnType("nvarchar(max)");
b.Property<bool>("IsDeleted")
.HasColumnType("bit");
b.Property<bool>("IsMobileVerified")
.HasColumnType("bit");
b.Property<bool>("IsRulesAccepted")
.HasColumnType("bit");
b.Property<DateTime?>("LastModified")
.HasColumnType("datetime2");
b.Property<string>("LastModifiedBy")
.HasColumnType("nvarchar(max)");
b.Property<string>("LastName")
.HasColumnType("nvarchar(max)");
b.Property<string>("Mobile")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<DateTime?>("MobileVerifiedAt")
.HasColumnType("datetime2");
b.Property<string>("NationalCode")
.HasColumnType("nvarchar(max)");
b.Property<long?>("ParentId")
.HasColumnType("bigint");
b.Property<bool>("PushNotifications")
.HasColumnType("bit");
b.Property<string>("ReferralCode")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<DateTime?>("RulesAcceptedAt")
.HasColumnType("datetime2");
b.Property<bool>("SmsNotifications")
.HasColumnType("bit");
b.HasKey("Id");
b.HasIndex("ParentId");
b.ToTable("Users", "CMS");
});
modelBuilder.Entity("CMSMicroservice.Domain.Entities.UserAddress", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("bigint");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<long>("Id"));
b.Property<string>("Address")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<long>("CityId")
.HasColumnType("bigint");
b.Property<DateTime>("Created")
.HasColumnType("datetime2");
b.Property<string>("CreatedBy")
.HasColumnType("nvarchar(max)");
b.Property<bool>("IsDefault")
.HasColumnType("bit");
b.Property<bool>("IsDeleted")
.HasColumnType("bit");
b.Property<DateTime?>("LastModified")
.HasColumnType("datetime2");
b.Property<string>("LastModifiedBy")
.HasColumnType("nvarchar(max)");
b.Property<string>("PostalCode")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("Title")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<long>("UserId")
.HasColumnType("bigint");
b.HasKey("Id");
b.HasIndex("UserId");
b.ToTable("UserAddresss", "CMS");
});
modelBuilder.Entity("CMSMicroservice.Domain.Entities.UserOrder", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("bigint");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<long>("Id"));
b.Property<DateTime>("Created")
.HasColumnType("datetime2");
b.Property<string>("CreatedBy")
.HasColumnType("nvarchar(max)");
b.Property<bool>("IsDeleted")
.HasColumnType("bit");
b.Property<DateTime?>("LastModified")
.HasColumnType("datetime2");
b.Property<string>("LastModifiedBy")
.HasColumnType("nvarchar(max)");
b.Property<long>("PackageId")
.HasColumnType("bigint");
b.Property<DateTime?>("PaymentDate")
.HasColumnType("datetime2");
b.Property<bool>("PaymentStatus")
.HasColumnType("bit");
b.Property<long>("Price")
.HasColumnType("bigint");
b.Property<long?>("TransactionId")
.HasColumnType("bigint");
b.Property<long>("UserAddressId")
.HasColumnType("bigint");
b.Property<long>("UserId")
.HasColumnType("bigint");
b.HasKey("Id");
b.HasIndex("PackageId");
b.HasIndex("UserAddressId");
b.HasIndex("UserId");
b.ToTable("UserOrders", "CMS");
});
modelBuilder.Entity("CMSMicroservice.Domain.Entities.UserRole", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("bigint");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<long>("Id"));
b.Property<DateTime>("Created")
.HasColumnType("datetime2");
b.Property<string>("CreatedBy")
.HasColumnType("nvarchar(max)");
b.Property<bool>("IsDeleted")
.HasColumnType("bit");
b.Property<DateTime?>("LastModified")
.HasColumnType("datetime2");
b.Property<string>("LastModifiedBy")
.HasColumnType("nvarchar(max)");
b.Property<long>("RoleId")
.HasColumnType("bigint");
b.Property<long>("UserId")
.HasColumnType("bigint");
b.HasKey("Id");
b.HasIndex("RoleId");
b.HasIndex("UserId");
b.ToTable("UserRoles", "CMS");
});
modelBuilder.Entity("CMSMicroservice.Domain.Entities.User", b =>
{
b.HasOne("CMSMicroservice.Domain.Entities.User", "Parent")
.WithMany("Users")
.HasForeignKey("ParentId");
b.Navigation("Parent");
});
modelBuilder.Entity("CMSMicroservice.Domain.Entities.UserAddress", b =>
{
b.HasOne("CMSMicroservice.Domain.Entities.User", "User")
.WithMany("UserAddresss")
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("User");
});
modelBuilder.Entity("CMSMicroservice.Domain.Entities.UserOrder", b =>
{
b.HasOne("CMSMicroservice.Domain.Entities.Package", "Package")
.WithMany("UserOrders")
.HasForeignKey("PackageId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("CMSMicroservice.Domain.Entities.UserAddress", "UserAddress")
.WithMany("UserOrders")
.HasForeignKey("UserAddressId")
.OnDelete(DeleteBehavior.Restrict)
.IsRequired();
b.HasOne("CMSMicroservice.Domain.Entities.User", "User")
.WithMany("UserOrders")
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Package");
b.Navigation("User");
b.Navigation("UserAddress");
});
modelBuilder.Entity("CMSMicroservice.Domain.Entities.UserRole", b =>
{
b.HasOne("CMSMicroservice.Domain.Entities.Role", "Role")
.WithMany("UserRoles")
.HasForeignKey("RoleId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("CMSMicroservice.Domain.Entities.User", "User")
.WithMany("UserRoles")
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Role");
b.Navigation("User");
});
modelBuilder.Entity("CMSMicroservice.Domain.Entities.Package", b =>
{
b.Navigation("UserOrders");
});
modelBuilder.Entity("CMSMicroservice.Domain.Entities.Role", b =>
{
b.Navigation("UserRoles");
});
modelBuilder.Entity("CMSMicroservice.Domain.Entities.User", b =>
{
b.Navigation("UserAddresss");
b.Navigation("UserOrders");
b.Navigation("UserRoles");
b.Navigation("Users");
});
modelBuilder.Entity("CMSMicroservice.Domain.Entities.UserAddress", b =>
{
b.Navigation("UserOrders");
});
#pragma warning restore 612, 618
}
}
}

View File

@@ -0,0 +1,109 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace CMSMicroservice.Infrastructure.Persistence.Migrations
{
/// <inheritdoc />
public partial class u04 : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<DateTime>(
name: "BirthDate",
schema: "CMS",
table: "Users",
type: "datetime2",
nullable: true);
migrationBuilder.AddColumn<bool>(
name: "EmailNotifications",
schema: "CMS",
table: "Users",
type: "bit",
nullable: false,
defaultValue: false);
migrationBuilder.AddColumn<bool>(
name: "PushNotifications",
schema: "CMS",
table: "Users",
type: "bit",
nullable: false,
defaultValue: false);
migrationBuilder.AddColumn<bool>(
name: "SmsNotifications",
schema: "CMS",
table: "Users",
type: "bit",
nullable: false,
defaultValue: false);
migrationBuilder.AddColumn<long>(
name: "UserAddressId",
schema: "CMS",
table: "UserOrders",
type: "bigint",
nullable: false,
defaultValue: 0L);
migrationBuilder.CreateIndex(
name: "IX_UserOrders_UserAddressId",
schema: "CMS",
table: "UserOrders",
column: "UserAddressId");
migrationBuilder.AddForeignKey(
name: "FK_UserOrders_UserAddresss_UserAddressId",
schema: "CMS",
table: "UserOrders",
column: "UserAddressId",
principalSchema: "CMS",
principalTable: "UserAddresss",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_UserOrders_UserAddresss_UserAddressId",
schema: "CMS",
table: "UserOrders");
migrationBuilder.DropIndex(
name: "IX_UserOrders_UserAddressId",
schema: "CMS",
table: "UserOrders");
migrationBuilder.DropColumn(
name: "BirthDate",
schema: "CMS",
table: "Users");
migrationBuilder.DropColumn(
name: "EmailNotifications",
schema: "CMS",
table: "Users");
migrationBuilder.DropColumn(
name: "PushNotifications",
schema: "CMS",
table: "Users");
migrationBuilder.DropColumn(
name: "SmsNotifications",
schema: "CMS",
table: "Users");
migrationBuilder.DropColumn(
name: "UserAddressId",
schema: "CMS",
table: "UserOrders");
}
}
}

View File

@@ -162,12 +162,18 @@ namespace CMSMicroservice.Infrastructure.Persistence.Migrations
b.Property<string>("AvatarPath")
.HasColumnType("nvarchar(max)");
b.Property<DateTime?>("BirthDate")
.HasColumnType("datetime2");
b.Property<DateTime>("Created")
.HasColumnType("datetime2");
b.Property<string>("CreatedBy")
.HasColumnType("nvarchar(max)");
b.Property<bool>("EmailNotifications")
.HasColumnType("bit");
b.Property<string>("FirstName")
.HasColumnType("nvarchar(max)");
@@ -202,6 +208,9 @@ namespace CMSMicroservice.Infrastructure.Persistence.Migrations
b.Property<long?>("ParentId")
.HasColumnType("bigint");
b.Property<bool>("PushNotifications")
.HasColumnType("bit");
b.Property<string>("ReferralCode")
.IsRequired()
.HasColumnType("nvarchar(max)");
@@ -209,6 +218,9 @@ namespace CMSMicroservice.Infrastructure.Persistence.Migrations
b.Property<DateTime?>("RulesAcceptedAt")
.HasColumnType("datetime2");
b.Property<bool>("SmsNotifications")
.HasColumnType("bit");
b.HasKey("Id");
b.HasIndex("ParentId");
@@ -305,6 +317,9 @@ namespace CMSMicroservice.Infrastructure.Persistence.Migrations
b.Property<long?>("TransactionId")
.HasColumnType("bigint");
b.Property<long>("UserAddressId")
.HasColumnType("bigint");
b.Property<long>("UserId")
.HasColumnType("bigint");
@@ -312,6 +327,8 @@ namespace CMSMicroservice.Infrastructure.Persistence.Migrations
b.HasIndex("PackageId");
b.HasIndex("UserAddressId");
b.HasIndex("UserId");
b.ToTable("UserOrders", "CMS");
@@ -383,6 +400,12 @@ namespace CMSMicroservice.Infrastructure.Persistence.Migrations
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("CMSMicroservice.Domain.Entities.UserAddress", "UserAddress")
.WithMany("UserOrders")
.HasForeignKey("UserAddressId")
.OnDelete(DeleteBehavior.Restrict)
.IsRequired();
b.HasOne("CMSMicroservice.Domain.Entities.User", "User")
.WithMany("UserOrders")
.HasForeignKey("UserId")
@@ -392,6 +415,8 @@ namespace CMSMicroservice.Infrastructure.Persistence.Migrations
b.Navigation("Package");
b.Navigation("User");
b.Navigation("UserAddress");
});
modelBuilder.Entity("CMSMicroservice.Domain.Entities.UserRole", b =>
@@ -433,6 +458,11 @@ namespace CMSMicroservice.Infrastructure.Persistence.Migrations
b.Navigation("Users");
});
modelBuilder.Entity("CMSMicroservice.Domain.Entities.UserAddress", b =>
{
b.Navigation("UserOrders");
});
#pragma warning restore 612, 618
}
}