Compare commits

..

14 Commits

Author SHA1 Message Date
dee6bc7bef feat: add person name and insert time to announcement DTO
- Added PersonName property to AnnouncementDto to display person's full name
- Added lookup logic to fetch person names from Persons table based on phone numbers
- Added InsertTime shadow property retrieval from EF Core to display creation date
- Updated model snapshot with new shadow properties (InsertTime, IsRemoved, RemoveTime, UpdateTime) for Chat entity
2026-06-11 19:42:58 +03:30
861a98668e feat: add Auditable attribute to Chat entity and create migration
Added [Auditable] attribute to the Chat entity to enable auditing functionality. Created a new migration (AddAuditableToChat) that adds InsertTime, IsRemoved, and RemoveTime columns to the Chat table, along with the necessary database schema updates to support the auditing behavior.
2026-06-11 19:42:44 +03:30
e4fe2389a4 feat: add unit filtering and improve unit info handling in charge cycles
- Add optional UnitId parameter to CostCyclsList method for filtering cycles by specific unit
- Replace UnitIds/UnitNames lists with structured UnitInfoDto containing Id and Name
- Clean unit names by removing "GUID#" prefix when present
- Update CostCycleDto to use UnitInfoDto list instead of separate Id and Name lists
- Fix unit assignment logic in Add and Edit methods to use new DTO structure
2026-06-10 20:17:46 +03:30
3bc209839e refactor: extract DateTime.Now conversion to variable for reuse 2026-06-09 23:50:13 +03:30
f2880a2167 feat(dashboard): add optional CommonRequestDto parameter to GetManagerSummary
Add optional CommonRequestDto parameter to GetManagerSummary method in both service interface and implementation, and update the controller endpoint to accept it as a query parameter. This allows passing common request data (e.g., pagination, filtering) to the dashboard summary retrieval.
2026-06-09 23:35:16 +03:30
adcee56ce8 fix: update migration timestamp and correct city IDs in data seeder
- Update EF Core migration history timestamp from 20260608225159 to 20260608225845
- Fix CityId values in Complex seed data to use new composite format (provinceId*100+cityId)
  - Tehran: 1 → 801 (provinceId=8, cityId=1)
  - Isfahan: 3 → 401 (provinceId=4, cityId=1)
2026-06-09 02:45:46 +03:30
0e1b0345ec feat: disable identity auto-generation for reference/lookup tables
Reference tables (Province, City, BasicTable, IncomeCostTitle, UnitState, Transaction) require stable, manually assigned IDs that are cross-referenced by other entities. Identity auto-generation is disabled to allow explicit ID assignment from seed data.
2026-06-09 02:40:13 +03:30
6644db7e78 fix(db): update migration and configure many-to-many relationships to avoid cascade paths
- Regenerated InitialCreate migration to reflect new entity configurations
- Configured many-to-many relationship between CostCycle and Unit with NoAction on Unit side to prevent multiple cascade paths
- Updated UnitCost relationships: Cascade from CostCycle, NoAction from Unit
- Removed commented-out global filter code and replaced with explicit relationship configurations
2026-06-09 02:23:09 +03:30
569e39b58d Fix 'Invalid object name Provinces' error - reset migrations and switch to Migrate() 2026-06-09 02:13:29 +03:30
7a4190ca13 feat: add Province and City DbSets to ComplexDBContext 2026-06-09 01:58:05 +03:30
7e54818332 fix: use EnsureCreated instead of Migrate to handle missing initial migration 2026-06-09 01:52:29 +03:30
2c87b5bd49 fix: correct CORS middleware name and remove unused TLS certresolver comment
The CORS middleware was incorrectly referencing `webapp-cors` for the `accessControlAllowCredentials` header, which should use `complex-cors` to match the actual middleware name. Also removed a commented-out TLS certresolver line that was no longer needed.
2026-06-09 01:44:29 +03:30
13deea7f3f fix(docker-compose): rename connection string environment variable
Updated the connection string environment variable from `ConnectionStrings__Default` to `ConnectionStrings__ComplexConnection` to align with the application's expected configuration key.
2026-06-09 01:41:49 +03:30
3536ff62c1 fix: update manager phone number in seed data from 09120000001 to 09354600904
Changed the manager's mobile number across all seed data entries to reflect the correct contact information for the complex manager.
2026-06-09 01:40:26 +03:30
19 changed files with 2171 additions and 263 deletions

View File

@@ -33,14 +33,37 @@ namespace Complex.Application.Services.Announcement
.Take(pageSize)
.ToList();
var result = chats.Select(c => new AnnouncementDto
// Get unique phone numbers to look up person names
var phoneNumbers = chats
.Select(c => c.PersonMobileNumber)
.Where(p => p != null)
.Distinct()
.ToList();
var personNames = _complexDBContext.Persons
.Where(p => phoneNumbers.Contains(p.Id))
.ToDictionary(p => p.Id, p => $"{p.FirstName} {p.LastName}".Trim());
var result = chats.Select(c =>
{
Id = c.Id,
ComplexId = c.ComplexId,
PersonMobileNumber = c.PersonMobileNumber,
Body = c.Body,
ChatTypeId = c.ChatTypeId,
InsertTime = null // InsertTime is set by Auditable attribute in SaveChanges, not a property on Chat entity
personNames.TryGetValue(c.PersonMobileNumber, out var personName);
// Read InsertTime from EF Core shadow property
var insertTimeEntry = _complexDBContext.Entry(c).Property("InsertTime");
var insertTime = insertTimeEntry?.CurrentValue as DateTime?;
return new AnnouncementDto
{
Id = c.Id,
ComplexId = c.ComplexId,
PersonMobileNumber = c.PersonMobileNumber,
PersonName = personName,
Body = c.Body,
ChatTypeId = c.ChatTypeId,
InsertTime = insertTime.HasValue
? insertTime.Value.ToString("yyyy/MM/dd HH:mm")
: null
};
}).ToList();
return new ResultDto<List<AnnouncementDto>>
@@ -78,6 +101,7 @@ namespace Complex.Application.Services.Announcement
public long Id { get; set; }
public Guid ComplexId { get; set; }
public string? PersonMobileNumber { get; set; }
public string? PersonName { get; set; }
public string? Body { get; set; }
public byte? ChatTypeId { get; set; }
public string? InsertTime { get; set; }

View File

@@ -52,7 +52,7 @@ namespace Complex.Application.Services.Basic
/// <param name="IncomeCostTitleId"></param>
/// <returns></returns>
public ResultDto<List<CostCycleDto>> CostCyclsList(Guid ComplexId, DateOnly? StartDate = null,
DateOnly? EndDate = null, int? IncomeCostTitleId = null)
DateOnly? EndDate = null, int? IncomeCostTitleId = null, Guid? UnitId = null)
{
if (IncomeCostTitleId.HasValue && StartDate.HasValue)
StartDate = GetStartOfMonth(StartDate.Value);
@@ -70,6 +70,9 @@ namespace Complex.Application.Services.Basic
else/*مدیریت شارژ ها فقط*/
ChargeCycleQuery = ChargeCycleQuery.Where(c => c.IncomeCostTitleId == null);
if (UnitId.HasValue)
ChargeCycleQuery = ChargeCycleQuery.Where(c => c.Units == null || c.Units.Any(u => u.Id == UnitId.Value));
var ChargeCycleList = ChargeCycleQuery.ToList().Select(c => new CostCycleDto
{
ComplexId = c.ComplexId,
@@ -80,8 +83,18 @@ namespace Complex.Application.Services.Basic
StartDate = c.StartDate,
Id = c.Id,
Title = c.Title,
UnitIds = c.Units?.Select(u => u.Id).ToList(),
UnitNames = c.Units?.Select(u => u.Id + "#" + u.UnitName).ToList(),
Units = c.Units?.Select(u =>
{
var name = u.UnitName ?? "";
// Some units store "GUID#Name" format; extract just the name part
var hashIndex = name.IndexOf('#');
var cleanName = hashIndex >= 0 ? name[(hashIndex + 1)..] : name;
return new UnitInfoDto
{
Id = u.Id,
Name = cleanName
};
}).ToList(),
IncomeCostTitleId = c.IncomeCostTitleId,
IncomeCostTitle = c.IncomeCostTitle?.Title
}).ToList();
@@ -107,9 +120,12 @@ namespace Complex.Application.Services.Basic
cycle = _mapper.Map<CostCycle>(costCycleDto);
cycle.IncomeCostTitleId = costCycleDto.IncomeCostTitleId;
if (costCycleDto.UnitIds != null)
cycle.Units = _complexDBContext.Units.Where(u => costCycleDto.UnitIds.Contains(u.Id)
if (costCycleDto.Units != null)
{
var unitIds = costCycleDto.Units.Select(u => u.Id).ToList();
cycle.Units = _complexDBContext.Units.Where(u => unitIds.Contains(u.Id)
&& u.ComplexId == costCycleDto.ComplexId).ToList();
}
foreach (var u in cycle.Units)
{
@@ -139,8 +155,11 @@ namespace Complex.Application.Services.Basic
costCycleDto.StartDate = GetStartOfMonth(costCycleDto.StartDate);
var newCycle = _mapper.Map<CostCycle>(costCycleDto);
if (costCycleDto.UnitIds != null)
newCycle.Units = _complexDBContext.Units.Where(u => costCycleDto.UnitIds.Contains(u.Id) && costCycleDto.ComplexId == u.ComplexId).ToList();
if (costCycleDto.Units != null)
{
var unitIds = costCycleDto.Units.Select(u => u.Id).ToList();
newCycle.Units = _complexDBContext.Units.Where(u => unitIds.Contains(u.Id) && costCycleDto.ComplexId == u.ComplexId).ToList();
}
//if(newCycle.Units==null)
//{
@@ -381,6 +400,12 @@ namespace Complex.Application.Services.Basic
public string? CostTitle { get; set; }
public DateOnly? PaymentDate { set; get; }
}
public class UnitInfoDto
{
public Guid Id { set; get; }
public string Name { set; get; }
}
public class CostCycleDto
{
public Guid Id { set; get; }
@@ -400,13 +425,9 @@ namespace Complex.Application.Services.Basic
/// <summary>
/// اگر برای واحدهای خاصی بود
/// </summary>
public virtual List<UnitInfoDto>? Units { set; get; }
/// <summary>
/// اگر برای واحدهای خاصی بود
/// </summary>
public virtual List<Guid>? UnitIds { set; get; }
public virtual List<string>? UnitNames { set; get; }
/// <summary>
/// null یعنی شارژ
/// null یعنی شارژ
/// </summary>
public int? IncomeCostTitleId { set; get; }
public string? IncomeCostTitle { set; get; }

View File

@@ -1,4 +1,5 @@
using Complex.Application;
using Complex.Application.Common;
using Complex.Common.Dto;
using Complex.Domain.Entities;
using Microsoft.EntityFrameworkCore;
@@ -7,7 +8,7 @@ namespace Complex.Application.Services.Dashboard
{
public interface IDashboardService
{
ResultDto<DashboardSummaryDto> GetManagerSummary(Guid complexId);
ResultDto<DashboardSummaryDto> GetManagerSummary(Guid complexId, CommonRequestDto? commonRequest = null);
}
public class DashboardService : IDashboardService
@@ -19,7 +20,7 @@ namespace Complex.Application.Services.Dashboard
_complexDBContext = complexDBContext;
}
public ResultDto<DashboardSummaryDto> GetManagerSummary(Guid complexId)
public ResultDto<DashboardSummaryDto> GetManagerSummary(Guid complexId, CommonRequestDto? commonRequest = null)
{
var units = _complexDBContext.Units.Where(u => u.ComplexId == complexId);
@@ -27,8 +28,9 @@ namespace Complex.Application.Services.Dashboard
var ownerUnits = units.Count(u => u.OwnerId != null);
var tenantUnits = units.Count(u => u.TenantId != null);
var today = DateOnly.FromDateTime(DateTime.Now);
var activeCostCycles = _complexDBContext.CostCycles
.Count(c => c.ComplexId == complexId && c.EndDate >= DateOnly.FromDateTime(DateTime.Now));
.Count(c => c.ComplexId == complexId && c.EndDate >= today);
var unitPersonMobileNumbers = units
.Where(u => u.OwnerId != null || u.TenantId != null)

View File

@@ -149,7 +149,7 @@ namespace Complex.Application.Complex
//وقتی واحد تازه ثبت شده پس در مدیریت شارژ قابلیت ثبت اختصاصی برای خودش نداشته پس باید شارژ عمومی برایش تعریف شود
// اگر خواست میتواند برایش به صورت اختصاصی هم ثبت کند که اون موقع برایش محاسبه مجدد خواهد شد
var costCycleDto = _costService.CostCyclsList(unit.ComplexId, nowDate, nowDate, null).Data
.FirstOrDefault(c => c.UnitIds == null);
.FirstOrDefault(c => c.Units == null);
if (costCycleDto != null)
{
//var costCycle = new CostCycle

View File

@@ -2,6 +2,7 @@
namespace Complex.Domain.Entities
{
[Auditable]
public class Chat:BaseEntity<long>
{
public Guid ComplexId { set; get; }

View File

@@ -1,8 +1,10 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;
namespace Complex.Domain.Entities
{
[Table("Cities")]
public partial class City
{
public City()

View File

@@ -1,8 +1,10 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;
namespace Complex.Domain.Entities
{
[Table("Provinces")]
public partial class Province
{
public Province()

View File

@@ -1,3 +1,4 @@
using Complex.Application.Common;
using Complex.Application.Services.Dashboard;
using Complex.Common.Dto;
using Complex.EndPoint.Utility;
@@ -20,9 +21,11 @@ namespace Complex.EndPoint.Controllers
}
[HttpGet]
public ResultDto<DashboardSummaryDto> ManagerSummary(Guid complexId)
public ResultDto<DashboardSummaryDto> ManagerSummary(
Guid complexId,
[FromQuery] CommonRequestDto? commonRequest)
{
return _dashboardService.GetManagerSummary(complexId);
return _dashboardService.GetManagerSummary(complexId, commonRequest);
}
}
}

View File

@@ -41,11 +41,12 @@ namespace Complex.EndPoint.Controllers
/// <param name="EndDate"></param>
/// <returns></returns>
[HttpPost]
public ResultDto<List<CostCycleDto>> CostCyclsList([FromForm] Guid ComplexId, [FromForm] DateTime? StartDate = null, [FromForm] DateTime? EndDate = null)
public ResultDto<List<CostCycleDto>> CostCyclsList([FromForm] Guid ComplexId, [FromForm] DateTime? StartDate = null, [FromForm] DateTime? EndDate = null, [FromForm] Guid? UnitId = null)
{
return _costCycleService.CostCyclsList(ComplexId,
!StartDate.HasValue ? null : DateOnly.FromDateTime(StartDate.Value),
!EndDate.HasValue ? null : DateOnly.FromDateTime(EndDate.Value));
!EndDate.HasValue ? null : DateOnly.FromDateTime(EndDate.Value),
UnitId: UnitId);
}
/// <summary>
/// بدهی یک واحد

View File

@@ -123,6 +123,7 @@ builder.Services.AddDbContext<ComplexDBContext>(
);
*/
builder.Services.AddApiVersioning(Options =>
{
Options.AssumeDefaultVersionWhenUnspecified = true;
@@ -177,10 +178,38 @@ builder.Services.AddSwaggerGen(c =>
var app = builder.Build();
// Apply pending migrations automatically on startup
// Apply pending migrations and create database if not exists
using (var scope = app.Services.CreateScope())
{
var dbContext = scope.ServiceProvider.GetRequiredService<ComplexDBContext>();
// If the database was previously created with EnsureCreated() (no __EFMigrationsHistory),
// seed the history table so Migrate() knows the initial state
if (!dbContext.Database.GetAppliedMigrations().Any())
{
try
{
// Check if any tables exist (meaning EnsureCreated was used before)
var tableCount = dbContext.Database.ExecuteSqlRaw(
"SELECT COUNT(*) FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_TYPE = 'BASE TABLE'");
if (tableCount > 0)
{
// Create __EFMigrationsHistory if it doesn't exist and seed it
dbContext.Database.ExecuteSqlRaw(
"IF NOT EXISTS (SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = '__EFMigrationsHistory') " +
"BEGIN " +
"CREATE TABLE [__EFMigrationsHistory] ([MigrationId] nvarchar(150) NOT NULL, [ProductVersion] nvarchar(32) NOT NULL, PRIMARY KEY ([MigrationId])); " +
"END " +
"IF NOT EXISTS (SELECT * FROM __EFMigrationsHistory WHERE MigrationId = '20260608225845_InitialCreate') " +
"INSERT INTO __EFMigrationsHistory (MigrationId, ProductVersion) VALUES ('20260608225845_InitialCreate', '6.0.3')");
}
}
catch
{
// Database doesn't exist yet, Migrate() will create it
}
}
dbContext.Database.Migrate();
// Seed essential reference data and test data
await DataSeeder.SeedAsync(dbContext);

View File

@@ -53,19 +53,67 @@ namespace Complex.Infrastructure
builder.Entity<Unit>().HasQueryFilter(b => EF.Property<bool>(b, "IsRemoved") == false);
builder.Entity<UnitCost>().HasQueryFilter(b => EF.Property<bool>(b, "IsRemoved") == false);
builder.Entity<CostCycle>().HasQueryFilter(b => EF.Property<bool>(b, "IsRemoved") == false);
//builder.ApplyGlobalFilters<bool>("IsRemoved", false);
// var allEntities = modelBuilder.Model.GetEntityTypes();
//Expression<Func<IMutableEntityType, bool>> filterExpr = bm => (bm.GetProperty("IsRemoved").ToString() == "0");
//foreach (var entity in builder.Model.GetEntityTypes())
//{
// //if (!entity.ClrType.IsAssignableTo(typeof(BaseEntity)))
// // continue;
// if (entity.ClrType.GetCustomAttributes(typeof(AuditableAttribute), true).Length > 0)
// entity
// //entity.SetQueryFilter(filterExpr);
//}
// Configure many-to-many between CostCycle and Unit
// SQL Server does not allow multiple cascade paths, so one side must use NoAction
builder.Entity<CostCycle>()
.HasMany(cc => cc.Units)
.WithMany(u => u.CostCycles)
.UsingEntity<Dictionary<string, object>>(
"CostCycleUnit",
j => j.HasOne<Unit>().WithMany().HasForeignKey("UnitsId").OnDelete(DeleteBehavior.NoAction),
j => j.HasOne<CostCycle>().WithMany().HasForeignKey("CostCyclesId").OnDelete(DeleteBehavior.Cascade));
// Configure UnitCost relationships to avoid multiple cascade paths
// UnitCost -> CostCycle (Cascade) and UnitCost -> Unit (NoAction)
builder.Entity<UnitCost>()
.HasOne(uc => uc.CostCycle)
.WithMany()
.HasForeignKey(uc => uc.CostCycleId)
.OnDelete(DeleteBehavior.Cascade);
builder.Entity<UnitCost>()
.HasOne(uc => uc.Unit)
.WithMany()
.HasForeignKey(uc => uc.UnitId)
.OnDelete(DeleteBehavior.NoAction);
// ============================================================
// Reference/Lookup tables: These have fixed, meaningful IDs
// that are explicitly set in seed data and cross-referenced
// by other entities. Identity auto-generation must be disabled.
// ============================================================
// Province: ProvinceId (1-31) are stable identifiers
builder.Entity<Province>()
.Property(p => p.ProvinceId)
.ValueGeneratedNever();
// City: CityId (101, 102, ...) are meaningful (provinceId * 100 + index)
builder.Entity<City>()
.Property(c => c.CityId)
.ValueGeneratedNever();
// BasicTable (base for TransactionType): Id (1,2) are fixed reference data
builder.Entity<BasicTable>()
.Property(b => b.Id)
.ValueGeneratedNever();
// IncomeCostTitle: Id (1-12) are fixed reference data
builder.Entity<IncomeCostTitle>()
.Property(i => i.Id)
.ValueGeneratedNever();
// UnitState: Id (1-5) are fixed reference data
builder.Entity<UnitState>()
.Property(u => u.Id)
.ValueGeneratedNever();
// Transaction: Seeder uses explicit IDs (1,2,3) that are
// cross-referenced by UnitCost.TransactionId
builder.Entity<Transaction>()
.Property(t => t.Id)
.ValueGeneratedNever();
}
@@ -155,6 +203,8 @@ namespace Complex.Infrastructure
public virtual DbSet<UnitCost> UnitCosts { get; set; }
public virtual DbSet<UserToken> UserTokens { get; set; }
public virtual DbSet<SmsCode> SmsCodes { get; set; }
public virtual DbSet<Province> Provinces { get; set; }
public virtual DbSet<City> Cities { get; set; }
protected override void ConfigureConventions(ModelConfigurationBuilder builder)
{

View File

@@ -69,7 +69,7 @@ namespace Complex.Infrastructure
// ============================================================
var persons = new List<Person>
{
new() { Id = "09120000001", FirstName = "علی", LastName = "مدیر", Gender = 1, IsActive = true },
new() { Id = "09354600904", FirstName = "علی", LastName = "مدیر", Gender = 1, IsActive = true },
new() { Id = "09120000002", FirstName = "رضا", LastName = "ساکن", Gender = 1, IsActive = true },
new() { Id = "09120000003", FirstName = "مریم", LastName = "ساکنی", Gender = 2, IsActive = true },
new() { Id = "09120000004", FirstName = "مدیر", LastName = "سیستم", Gender = 1, IsActive = true },
@@ -98,7 +98,7 @@ namespace Complex.Infrastructure
Id = complexId1,
Title = "مجتمع بهاران",
Address = "تهران، خیابان ولیعصر، نبش کوچه بهار",
CityId = 1, // Tehran
CityId = 801, // Tehran (provinceId=8, cityId=8*100+1)
AreaMeter = 2000,
YardMeter = 500,
ElevatorCount = 2,
@@ -111,7 +111,7 @@ namespace Complex.Infrastructure
Id = complexId2,
Title = "مجتمع ساحل",
Address = "اصفهان، خیابان چهارباغ، روبروی پارک ساحل",
CityId = 3, // Isfahan
CityId = 401, // Isfahan (provinceId=4, cityId=4*100+1)
AreaMeter = 1500,
YardMeter = 300,
ElevatorCount = 1,
@@ -131,7 +131,7 @@ namespace Complex.Infrastructure
new()
{
ComplexId = complexId1,
ManagerMobileNumberId = "09120000001", // علی مدیر
ManagerMobileNumberId = "09354600904", // علی مدیر
StartDate = "1402/01/01",
EndDate = "1405/12/29"
},
@@ -151,7 +151,7 @@ namespace Complex.Infrastructure
// ============================================================
var complexPersons = new List<ComplexPerson>
{
new() { ComplexId = complexId1, PersonMobileNumberId = "09120000001" },
new() { ComplexId = complexId1, PersonMobileNumberId = "09354600904" },
new() { ComplexId = complexId1, PersonMobileNumberId = "09120000002" },
new() { ComplexId = complexId1, PersonMobileNumberId = "09120000003" },
new() { ComplexId = complexId1, PersonMobileNumberId = "09120000005" },
@@ -382,7 +382,7 @@ namespace Complex.Infrastructure
new()
{
ComplexId = complexId1,
PersonMobileNumber = "09120000001",
PersonMobileNumber = "09354600904",
Body = "سلام. شارژ فروردین ۵۰۰ هزار تومان است. مهلت پرداخت تا ۱۰ فروردین با تخفیف می‌باشد.",
ChatTypeId = 2
},
@@ -423,7 +423,7 @@ namespace Complex.Infrastructure
ComplexId = null,
UnitId = null,
EventDate = "1404/01/01",
RegisterMobileNumber = "09120000001",
RegisterMobileNumber = "09354600904",
Body = "سال نو مبارک",
Description = "تبریک سال نو به تمام ساکنین مجتمع"
},
@@ -438,13 +438,13 @@ namespace Complex.Infrastructure
{
new()
{
RegisterMobileNumber = "09120000001",
RegisterMobileNumber = "09354600904",
IsActive = true,
ImagePath = "/images/posters/banner1.jpg"
},
new()
{
RegisterMobileNumber = "09120000001",
RegisterMobileNumber = "09354600904",
IsActive = false,
ImagePath = "/images/posters/banner2.jpg"
},

View File

@@ -1,144 +0,0 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Complex.Infrastructure.Migrations
{
public partial class addcomplexPerson : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "ComplexPersons",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
ComplexId = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
PersonMobileNumberId = table.Column<string>(type: "nvarchar(450)", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_ComplexPersons", x => x.Id);
table.ForeignKey(
name: "FK_ComplexPersons_Persons_PersonMobileNumberId",
column: x => x.PersonMobileNumberId,
principalTable: "Persons",
principalColumn: "Id");
});
migrationBuilder.CreateIndex(
name: "IX_ComplexPersons_PersonMobileNumberId",
table: "ComplexPersons",
column: "PersonMobileNumberId");
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "ComplexPersons");
migrationBuilder.AlterColumn<DateTime>(
name: "InsertTime",
table: "UnitStates",
type: "datetime2",
nullable: false,
defaultValue: new DateTime(2025, 6, 1, 6, 15, 25, 234, DateTimeKind.Local).AddTicks(8929),
oldClrType: typeof(DateTime),
oldType: "datetime2",
oldDefaultValue: new DateTime(2025, 6, 1, 6, 17, 40, 44, DateTimeKind.Local).AddTicks(2122));
migrationBuilder.AlterColumn<DateTime>(
name: "InsertTime",
table: "Units",
type: "datetime2",
nullable: false,
defaultValue: new DateTime(2025, 6, 1, 6, 15, 25, 234, DateTimeKind.Local).AddTicks(3769),
oldClrType: typeof(DateTime),
oldType: "datetime2",
oldDefaultValue: new DateTime(2025, 6, 1, 6, 17, 40, 43, DateTimeKind.Local).AddTicks(7020));
migrationBuilder.AlterColumn<DateTime>(
name: "InsertTime",
table: "UnitCosts",
type: "datetime2",
nullable: false,
defaultValue: new DateTime(2025, 6, 1, 6, 15, 25, 234, DateTimeKind.Local).AddTicks(6906),
oldClrType: typeof(DateTime),
oldType: "datetime2",
oldDefaultValue: new DateTime(2025, 6, 1, 6, 17, 40, 44, DateTimeKind.Local).AddTicks(118));
migrationBuilder.AlterColumn<DateTime>(
name: "InsertTime",
table: "Transactions",
type: "datetime2",
nullable: false,
defaultValue: new DateTime(2025, 6, 1, 6, 15, 25, 234, DateTimeKind.Local).AddTicks(717),
oldClrType: typeof(DateTime),
oldType: "datetime2",
oldDefaultValue: new DateTime(2025, 6, 1, 6, 17, 40, 43, DateTimeKind.Local).AddTicks(3798));
migrationBuilder.AlterColumn<DateTime>(
name: "InsertTime",
table: "Persons",
type: "datetime2",
nullable: false,
defaultValue: new DateTime(2025, 6, 1, 6, 15, 25, 233, DateTimeKind.Local).AddTicks(7990),
oldClrType: typeof(DateTime),
oldType: "datetime2",
oldDefaultValue: new DateTime(2025, 6, 1, 6, 17, 40, 43, DateTimeKind.Local).AddTicks(1127));
migrationBuilder.AlterColumn<DateTime>(
name: "InsertTime",
table: "IncomeCostTitles",
type: "datetime2",
nullable: false,
defaultValue: new DateTime(2025, 6, 1, 6, 15, 25, 233, DateTimeKind.Local).AddTicks(5558),
oldClrType: typeof(DateTime),
oldType: "datetime2",
oldDefaultValue: new DateTime(2025, 6, 1, 6, 17, 40, 42, DateTimeKind.Local).AddTicks(8706));
migrationBuilder.AlterColumn<DateTime>(
name: "InsertTime",
table: "CostCycles",
type: "datetime2",
nullable: false,
defaultValue: new DateTime(2025, 6, 1, 6, 15, 25, 233, DateTimeKind.Local).AddTicks(2909),
oldClrType: typeof(DateTime),
oldType: "datetime2",
oldDefaultValue: new DateTime(2025, 6, 1, 6, 17, 40, 42, DateTimeKind.Local).AddTicks(6075));
migrationBuilder.AlterColumn<DateTime>(
name: "InsertTime",
table: "ComplexUnitEvents",
type: "datetime2",
nullable: false,
defaultValue: new DateTime(2025, 6, 1, 6, 15, 25, 233, DateTimeKind.Local).AddTicks(1398),
oldClrType: typeof(DateTime),
oldType: "datetime2",
oldDefaultValue: new DateTime(2025, 6, 1, 6, 17, 40, 42, DateTimeKind.Local).AddTicks(4581));
migrationBuilder.AlterColumn<DateTime>(
name: "InsertTime",
table: "ComplexManagers",
type: "datetime2",
nullable: false,
defaultValue: new DateTime(2025, 6, 1, 6, 15, 25, 232, DateTimeKind.Local).AddTicks(9811),
oldClrType: typeof(DateTime),
oldType: "datetime2",
oldDefaultValue: new DateTime(2025, 6, 1, 6, 17, 40, 42, DateTimeKind.Local).AddTicks(2979));
migrationBuilder.AlterColumn<DateTime>(
name: "InsertTime",
table: "ComplexEntities",
type: "datetime2",
nullable: false,
defaultValue: new DateTime(2025, 6, 1, 6, 15, 25, 232, DateTimeKind.Local).AddTicks(6954),
oldClrType: typeof(DateTime),
oldType: "datetime2",
oldDefaultValue: new DateTime(2025, 6, 1, 6, 17, 40, 42, DateTimeKind.Local).AddTicks(207));
}
}
}

View File

@@ -0,0 +1,993 @@
// <auto-generated />
using System;
using Complex.Infrastructure;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
#nullable disable
namespace Complex.Infrastructure.Migrations
{
[DbContext(typeof(ComplexDBContext))]
[Migration("20260608225845_InitialCreate")]
partial class InitialCreate
{
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "6.0.3")
.HasAnnotation("Relational:MaxIdentifierLength", 128);
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder, 1L, 1);
modelBuilder.Entity("Complex.Domain.Entities.BasicTable", b =>
{
b.Property<int>("Id")
.HasColumnType("int");
b.Property<string>("Discriminator")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("Title")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.ToTable("BasicTables");
b.HasDiscriminator<string>("Discriminator").HasValue("BasicTable");
});
modelBuilder.Entity("Complex.Domain.Entities.Chat", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("bigint");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<long>("Id"), 1L, 1);
b.Property<string>("Body")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<byte>("ChatTypeId")
.HasColumnType("tinyint");
b.Property<Guid>("ComplexId")
.HasColumnType("uniqueidentifier");
b.Property<string>("PersonMobileNumber")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.ToTable("Chats");
});
modelBuilder.Entity("Complex.Domain.Entities.City", b =>
{
b.Property<int>("CityId")
.HasColumnType("int");
b.Property<string>("CityTitle")
.HasColumnType("nvarchar(max)");
b.Property<int?>("ProvinceId")
.HasColumnType("int");
b.HasKey("CityId");
b.HasIndex("ProvinceId");
b.ToTable("Cities");
});
modelBuilder.Entity("Complex.Domain.Entities.ComplexEntity", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uniqueidentifier");
b.Property<string>("Address")
.HasColumnType("nvarchar(max)");
b.Property<int?>("AreaMeter")
.HasColumnType("int");
b.Property<int>("CityId")
.HasColumnType("int");
b.Property<string>("Description")
.HasColumnType("nvarchar(max)");
b.Property<int?>("ElevatorCount")
.HasColumnType("int");
b.Property<DateTime>("InsertTime")
.ValueGeneratedOnAdd()
.HasColumnType("datetime2")
.HasDefaultValue(new DateTime(2026, 6, 9, 2, 28, 45, 623, DateTimeKind.Local).AddTicks(7632));
b.Property<bool>("IsRemoved")
.ValueGeneratedOnAdd()
.HasColumnType("bit")
.HasDefaultValue(false);
b.Property<Guid?>("ParentId")
.HasColumnType("uniqueidentifier");
b.Property<DateTime?>("RemoveTime")
.HasColumnType("datetime2");
b.Property<int?>("StateId")
.HasColumnType("int");
b.Property<string>("Title")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<DateTime?>("UpdateTime")
.HasColumnType("datetime2");
b.Property<int?>("WarehouseCount")
.HasColumnType("int");
b.Property<int?>("YardMeter")
.HasColumnType("int");
b.Property<int?>("YearMake")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("CityId");
b.HasIndex("ParentId");
b.ToTable("ComplexEntities");
});
modelBuilder.Entity("Complex.Domain.Entities.ComplexManager", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"), 1L, 1);
b.Property<Guid>("ComplexId")
.HasColumnType("uniqueidentifier");
b.Property<string>("EndDate")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<DateTime>("InsertTime")
.ValueGeneratedOnAdd()
.HasColumnType("datetime2")
.HasDefaultValue(new DateTime(2026, 6, 9, 2, 28, 45, 624, DateTimeKind.Local).AddTicks(2426));
b.Property<bool>("IsRemoved")
.ValueGeneratedOnAdd()
.HasColumnType("bit")
.HasDefaultValue(false);
b.Property<string>("ManagerMobileNumberId")
.HasColumnType("nvarchar(450)");
b.Property<DateTime?>("RemoveTime")
.HasColumnType("datetime2");
b.Property<string>("StartDate")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<DateTime?>("UpdateTime")
.HasColumnType("datetime2");
b.HasKey("Id");
b.HasIndex("ComplexId");
b.HasIndex("ManagerMobileNumberId");
b.ToTable("ComplexManagers");
});
modelBuilder.Entity("Complex.Domain.Entities.ComplexPerson", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"), 1L, 1);
b.Property<Guid>("ComplexId")
.HasColumnType("uniqueidentifier");
b.Property<string>("PersonMobileNumberId")
.HasColumnType("nvarchar(450)");
b.HasKey("Id");
b.HasIndex("PersonMobileNumberId");
b.ToTable("ComplexPersons");
});
modelBuilder.Entity("Complex.Domain.Entities.ComplexUnitEvent", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("bigint");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<long>("Id"), 1L, 1);
b.Property<string>("Body")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<int?>("ComplexId")
.HasColumnType("int");
b.Property<string>("Description")
.HasColumnType("nvarchar(max)");
b.Property<string>("EventDate")
.IsRequired()
.HasMaxLength(10)
.HasColumnType("nvarchar(10)");
b.Property<DateTime>("InsertTime")
.ValueGeneratedOnAdd()
.HasColumnType("datetime2")
.HasDefaultValue(new DateTime(2026, 6, 9, 2, 28, 45, 624, DateTimeKind.Local).AddTicks(5016));
b.Property<bool>("IsRemoved")
.ValueGeneratedOnAdd()
.HasColumnType("bit")
.HasDefaultValue(false);
b.Property<string>("RegisterMobileNumber")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<DateTime?>("RemoveTime")
.HasColumnType("datetime2");
b.Property<Guid?>("UnitId")
.HasColumnType("uniqueidentifier");
b.Property<DateTime?>("UpdateTime")
.HasColumnType("datetime2");
b.HasKey("Id");
b.ToTable("ComplexUnitEvents");
});
modelBuilder.Entity("Complex.Domain.Entities.CostCycle", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uniqueidentifier");
b.Property<long>("Amount")
.HasColumnType("bigint");
b.Property<Guid>("ComplexId")
.HasColumnType("uniqueidentifier");
b.Property<long>("EncouragementAmount")
.HasColumnType("bigint");
b.Property<int>("EncouragementDay")
.HasColumnType("int");
b.Property<DateTime>("EndDate")
.HasColumnType("date");
b.Property<int?>("IncomeCostTitleId")
.HasColumnType("int");
b.Property<DateTime>("InsertTime")
.ValueGeneratedOnAdd()
.HasColumnType("datetime2")
.HasDefaultValue(new DateTime(2026, 6, 9, 2, 28, 45, 624, DateTimeKind.Local).AddTicks(7249));
b.Property<bool>("IsRemoved")
.ValueGeneratedOnAdd()
.HasColumnType("bit")
.HasDefaultValue(false);
b.Property<DateTime?>("RemoveTime")
.HasColumnType("datetime2");
b.Property<DateTime>("StartDate")
.HasColumnType("date");
b.Property<string>("Title")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<DateTime?>("UpdateTime")
.HasColumnType("datetime2");
b.HasKey("Id");
b.HasIndex("ComplexId");
b.HasIndex("IncomeCostTitleId");
b.ToTable("CostCycles");
});
modelBuilder.Entity("Complex.Domain.Entities.IncomeCostTitle", b =>
{
b.Property<int>("Id")
.HasColumnType("int");
b.Property<Guid?>("ComplexId")
.HasColumnType("uniqueidentifier");
b.Property<DateTime>("InsertTime")
.ValueGeneratedOnAdd()
.HasColumnType("datetime2")
.HasDefaultValue(new DateTime(2026, 6, 9, 2, 28, 45, 624, DateTimeKind.Local).AddTicks(9858));
b.Property<bool>("IsRemoved")
.ValueGeneratedOnAdd()
.HasColumnType("bit")
.HasDefaultValue(false);
b.Property<string>("RegisterMobileNumber")
.HasColumnType("nvarchar(max)");
b.Property<DateTime?>("RemoveTime")
.HasColumnType("datetime2");
b.Property<string>("Title")
.HasColumnType("nvarchar(max)");
b.Property<int>("TransactionTypeId")
.HasColumnType("int");
b.Property<DateTime?>("UpdateTime")
.HasColumnType("datetime2");
b.HasKey("Id");
b.HasIndex("ComplexId");
b.HasIndex("TransactionTypeId");
b.ToTable("IncomeCostTitles");
});
modelBuilder.Entity("Complex.Domain.Entities.Person", b =>
{
b.Property<string>("Id")
.HasColumnType("nvarchar(450)");
b.Property<byte[]>("Avatar")
.HasColumnType("varbinary(max)");
b.Property<string>("FirstName")
.HasColumnType("nvarchar(max)");
b.Property<byte?>("Gender")
.HasColumnType("tinyint");
b.Property<DateTime>("InsertTime")
.ValueGeneratedOnAdd()
.HasColumnType("datetime2")
.HasDefaultValue(new DateTime(2026, 6, 9, 2, 28, 45, 625, DateTimeKind.Local).AddTicks(1728));
b.Property<bool>("IsActive")
.HasColumnType("bit");
b.Property<bool>("IsRemoved")
.ValueGeneratedOnAdd()
.HasColumnType("bit")
.HasDefaultValue(false);
b.Property<string>("LastName")
.HasColumnType("nvarchar(max)");
b.Property<DateTime?>("RemoveTime")
.HasColumnType("datetime2");
b.Property<DateTime?>("UpdateTime")
.HasColumnType("datetime2");
b.HasKey("Id");
b.ToTable("Persons");
});
modelBuilder.Entity("Complex.Domain.Entities.Poster", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"), 1L, 1);
b.Property<string>("ImagePath")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<bool>("IsActive")
.HasColumnType("bit");
b.Property<string>("RegisterMobileNumber")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.ToTable("Posters");
});
modelBuilder.Entity("Complex.Domain.Entities.Province", b =>
{
b.Property<int>("ProvinceId")
.HasColumnType("int");
b.Property<string>("ProvinceTitle")
.HasColumnType("nvarchar(max)");
b.HasKey("ProvinceId");
b.ToTable("Provinces");
});
modelBuilder.Entity("Complex.Domain.Entities.SmsCode", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"), 1L, 1);
b.Property<string>("Code")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<DateTime>("InsertDate")
.HasColumnType("datetime2");
b.Property<string>("PhoneNumber")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<int>("RequestCount")
.HasColumnType("int");
b.Property<bool>("Used")
.HasColumnType("bit");
b.HasKey("Id");
b.ToTable("SmsCodes");
});
modelBuilder.Entity("Complex.Domain.Entities.Transaction", b =>
{
b.Property<long>("Id")
.HasColumnType("bigint");
b.Property<long>("Amount")
.HasColumnType("bigint");
b.Property<Guid>("ComplexId")
.HasColumnType("uniqueidentifier");
b.Property<Guid?>("CostCycleId")
.HasColumnType("uniqueidentifier");
b.Property<string>("Description")
.HasColumnType("nvarchar(max)");
b.Property<string>("FicheId")
.HasColumnType("nvarchar(max)");
b.Property<DateTime>("InsertTime")
.ValueGeneratedOnAdd()
.HasColumnType("datetime2")
.HasDefaultValue(new DateTime(2026, 6, 9, 2, 28, 45, 625, DateTimeKind.Local).AddTicks(3921));
b.Property<bool>("IsRemoved")
.ValueGeneratedOnAdd()
.HasColumnType("bit")
.HasDefaultValue(false);
b.Property<string>("PersonId")
.IsRequired()
.HasColumnType("nvarchar(450)");
b.Property<DateTime?>("RemoveTime")
.HasColumnType("datetime2");
b.Property<DateTime>("TransactionDate")
.HasColumnType("datetime2");
b.Property<string>("TransactionPersianDate")
.IsRequired()
.HasMaxLength(10)
.HasColumnType("nvarchar(10)");
b.Property<int?>("TransactionTitleId")
.HasColumnType("int");
b.Property<long>("UnitCostId")
.HasColumnType("bigint");
b.Property<Guid?>("UnitId")
.HasColumnType("uniqueidentifier");
b.Property<DateTime?>("UpdateTime")
.HasColumnType("datetime2");
b.HasKey("Id");
b.HasIndex("CostCycleId");
b.HasIndex("PersonId");
b.HasIndex("TransactionTitleId");
b.HasIndex("UnitCostId")
.IsUnique();
b.HasIndex("UnitId");
b.ToTable("Transactions");
});
modelBuilder.Entity("Complex.Domain.Entities.Unit", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uniqueidentifier");
b.Property<int?>("AreaMeter")
.HasColumnType("int");
b.Property<Guid>("ComplexId")
.HasColumnType("uniqueidentifier");
b.Property<string>("EmergencyTels")
.HasColumnType("nvarchar(max)");
b.Property<int?>("Floor")
.HasColumnType("int");
b.Property<DateTime>("InsertTime")
.ValueGeneratedOnAdd()
.HasColumnType("datetime2")
.HasDefaultValue(new DateTime(2026, 6, 9, 2, 28, 45, 625, DateTimeKind.Local).AddTicks(7151));
b.Property<bool>("IsActive")
.HasColumnType("bit");
b.Property<bool>("IsRemoved")
.ValueGeneratedOnAdd()
.HasColumnType("bit")
.HasDefaultValue(false);
b.Property<string>("ManagerDescription")
.HasColumnType("nvarchar(max)");
b.Property<string>("OwnerId")
.HasColumnType("nvarchar(450)");
b.Property<int?>("ParkingAreaMeter")
.HasColumnType("int");
b.Property<string>("PublicState")
.HasColumnType("nvarchar(max)");
b.Property<DateTime?>("RemoveTime")
.HasColumnType("datetime2");
b.Property<int?>("StateId")
.HasColumnType("int");
b.Property<string>("TenantId")
.HasColumnType("nvarchar(450)");
b.Property<string>("UnitName")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<DateTime?>("UpdateTime")
.HasColumnType("datetime2");
b.Property<int?>("YardMeter")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("ComplexId");
b.HasIndex("OwnerId");
b.HasIndex("StateId");
b.HasIndex("TenantId");
b.ToTable("Units");
});
modelBuilder.Entity("Complex.Domain.Entities.UnitCost", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("bigint");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<long>("Id"), 1L, 1);
b.Property<Guid>("CostCycleId")
.HasColumnType("uniqueidentifier");
b.Property<DateTime>("Date")
.HasColumnType("date");
b.Property<DateTime>("InsertTime")
.ValueGeneratedOnAdd()
.HasColumnType("datetime2")
.HasDefaultValue(new DateTime(2026, 6, 9, 2, 28, 45, 625, DateTimeKind.Local).AddTicks(9764));
b.Property<bool>("IsRemoved")
.ValueGeneratedOnAdd()
.HasColumnType("bit")
.HasDefaultValue(false);
b.Property<DateTime?>("RemoveTime")
.HasColumnType("datetime2");
b.Property<int?>("TransactionId")
.HasColumnType("int");
b.Property<Guid>("UnitId")
.HasColumnType("uniqueidentifier");
b.Property<DateTime?>("UpdateTime")
.HasColumnType("datetime2");
b.HasKey("Id");
b.HasIndex("CostCycleId");
b.HasIndex("UnitId");
b.ToTable("UnitCosts");
});
modelBuilder.Entity("Complex.Domain.Entities.UnitState", b =>
{
b.Property<int>("Id")
.HasColumnType("int");
b.Property<Guid?>("ComplexId")
.HasColumnType("uniqueidentifier");
b.Property<string>("Icon")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<DateTime>("InsertTime")
.ValueGeneratedOnAdd()
.HasColumnType("datetime2")
.HasDefaultValue(new DateTime(2026, 6, 9, 2, 28, 45, 626, DateTimeKind.Local).AddTicks(1646));
b.Property<bool>("IsRemoved")
.ValueGeneratedOnAdd()
.HasColumnType("bit")
.HasDefaultValue(false);
b.Property<DateTime?>("RemoveTime")
.HasColumnType("datetime2");
b.Property<string>("Title")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<DateTime?>("UpdateTime")
.HasColumnType("datetime2");
b.HasKey("Id");
b.ToTable("UnitStates");
});
modelBuilder.Entity("Complex.Domain.Entities.UserToken", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"), 1L, 1);
b.Property<string>("MobileModel")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("PersonId")
.IsRequired()
.HasColumnType("nvarchar(450)");
b.Property<string>("RefreshToken")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<DateTime>("RefreshTokenExp")
.HasColumnType("datetime2");
b.Property<DateTime>("TokenExp")
.HasColumnType("datetime2");
b.Property<string>("TokenHash")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.HasIndex("PersonId");
b.ToTable("UserTokens");
});
modelBuilder.Entity("CostCycleUnit", b =>
{
b.Property<Guid>("CostCyclesId")
.HasColumnType("uniqueidentifier");
b.Property<Guid>("UnitsId")
.HasColumnType("uniqueidentifier");
b.HasKey("CostCyclesId", "UnitsId");
b.HasIndex("UnitsId");
b.ToTable("CostCycleUnit");
});
modelBuilder.Entity("Complex.Domain.Entities.TransactionType", b =>
{
b.HasBaseType("Complex.Domain.Entities.BasicTable");
b.HasDiscriminator().HasValue("TransactionType");
});
modelBuilder.Entity("Complex.Domain.Entities.City", b =>
{
b.HasOne("Complex.Domain.Entities.Province", "Province")
.WithMany("Cities")
.HasForeignKey("ProvinceId");
b.Navigation("Province");
});
modelBuilder.Entity("Complex.Domain.Entities.ComplexEntity", b =>
{
b.HasOne("Complex.Domain.Entities.City", "City")
.WithMany()
.HasForeignKey("CityId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Complex.Domain.Entities.ComplexEntity", "Parent")
.WithMany()
.HasForeignKey("ParentId");
b.Navigation("City");
b.Navigation("Parent");
});
modelBuilder.Entity("Complex.Domain.Entities.ComplexManager", b =>
{
b.HasOne("Complex.Domain.Entities.ComplexEntity", "Complex")
.WithMany("ComplexManagers")
.HasForeignKey("ComplexId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Complex.Domain.Entities.Person", "ManagerMobileNumber")
.WithMany()
.HasForeignKey("ManagerMobileNumberId");
b.Navigation("Complex");
b.Navigation("ManagerMobileNumber");
});
modelBuilder.Entity("Complex.Domain.Entities.ComplexPerson", b =>
{
b.HasOne("Complex.Domain.Entities.Person", "PersonMobileNumber")
.WithMany()
.HasForeignKey("PersonMobileNumberId");
b.Navigation("PersonMobileNumber");
});
modelBuilder.Entity("Complex.Domain.Entities.CostCycle", b =>
{
b.HasOne("Complex.Domain.Entities.ComplexEntity", "Complex")
.WithMany()
.HasForeignKey("ComplexId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Complex.Domain.Entities.IncomeCostTitle", "IncomeCostTitle")
.WithMany()
.HasForeignKey("IncomeCostTitleId");
b.Navigation("Complex");
b.Navigation("IncomeCostTitle");
});
modelBuilder.Entity("Complex.Domain.Entities.IncomeCostTitle", b =>
{
b.HasOne("Complex.Domain.Entities.ComplexEntity", "Complex")
.WithMany()
.HasForeignKey("ComplexId");
b.HasOne("Complex.Domain.Entities.TransactionType", "TransactionType")
.WithMany()
.HasForeignKey("TransactionTypeId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Complex");
b.Navigation("TransactionType");
});
modelBuilder.Entity("Complex.Domain.Entities.Transaction", b =>
{
b.HasOne("Complex.Domain.Entities.CostCycle", "CostCycle")
.WithMany()
.HasForeignKey("CostCycleId");
b.HasOne("Complex.Domain.Entities.Person", "Person")
.WithMany()
.HasForeignKey("PersonId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Complex.Domain.Entities.IncomeCostTitle", "TransactionTitle")
.WithMany()
.HasForeignKey("TransactionTitleId");
b.HasOne("Complex.Domain.Entities.UnitCost", "UnitCost")
.WithOne("Transaction")
.HasForeignKey("Complex.Domain.Entities.Transaction", "UnitCostId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Complex.Domain.Entities.Unit", "Unit")
.WithMany()
.HasForeignKey("UnitId");
b.Navigation("CostCycle");
b.Navigation("Person");
b.Navigation("TransactionTitle");
b.Navigation("Unit");
b.Navigation("UnitCost");
});
modelBuilder.Entity("Complex.Domain.Entities.Unit", b =>
{
b.HasOne("Complex.Domain.Entities.ComplexEntity", "Complex")
.WithMany("Units")
.HasForeignKey("ComplexId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Complex.Domain.Entities.Person", "Owner")
.WithMany()
.HasForeignKey("OwnerId");
b.HasOne("Complex.Domain.Entities.UnitState", "State")
.WithMany()
.HasForeignKey("StateId");
b.HasOne("Complex.Domain.Entities.Person", "Tenant")
.WithMany()
.HasForeignKey("TenantId");
b.Navigation("Complex");
b.Navigation("Owner");
b.Navigation("State");
b.Navigation("Tenant");
});
modelBuilder.Entity("Complex.Domain.Entities.UnitCost", b =>
{
b.HasOne("Complex.Domain.Entities.CostCycle", "CostCycle")
.WithMany()
.HasForeignKey("CostCycleId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Complex.Domain.Entities.Unit", "Unit")
.WithMany()
.HasForeignKey("UnitId")
.OnDelete(DeleteBehavior.NoAction)
.IsRequired();
b.Navigation("CostCycle");
b.Navigation("Unit");
});
modelBuilder.Entity("Complex.Domain.Entities.UserToken", b =>
{
b.HasOne("Complex.Domain.Entities.Person", "Person")
.WithMany("UserTokens")
.HasForeignKey("PersonId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Person");
});
modelBuilder.Entity("CostCycleUnit", b =>
{
b.HasOne("Complex.Domain.Entities.CostCycle", null)
.WithMany()
.HasForeignKey("CostCyclesId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Complex.Domain.Entities.Unit", null)
.WithMany()
.HasForeignKey("UnitsId")
.OnDelete(DeleteBehavior.NoAction)
.IsRequired();
});
modelBuilder.Entity("Complex.Domain.Entities.ComplexEntity", b =>
{
b.Navigation("ComplexManagers");
b.Navigation("Units");
});
modelBuilder.Entity("Complex.Domain.Entities.Person", b =>
{
b.Navigation("UserTokens");
});
modelBuilder.Entity("Complex.Domain.Entities.Province", b =>
{
b.Navigation("Cities");
});
modelBuilder.Entity("Complex.Domain.Entities.UnitCost", b =>
{
b.Navigation("Transaction")
.IsRequired();
});
#pragma warning restore 612, 618
}
}
}

View File

@@ -0,0 +1,671 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Complex.Infrastructure.Migrations
{
public partial class InitialCreate : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "BasicTables",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false),
Title = table.Column<string>(type: "nvarchar(max)", nullable: false),
Discriminator = table.Column<string>(type: "nvarchar(max)", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_BasicTables", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Chats",
columns: table => new
{
Id = table.Column<long>(type: "bigint", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
ComplexId = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
PersonMobileNumber = table.Column<string>(type: "nvarchar(max)", nullable: false),
Body = table.Column<string>(type: "nvarchar(max)", nullable: false),
ChatTypeId = table.Column<byte>(type: "tinyint", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Chats", x => x.Id);
});
migrationBuilder.CreateTable(
name: "ComplexUnitEvents",
columns: table => new
{
Id = table.Column<long>(type: "bigint", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
UnitId = table.Column<Guid>(type: "uniqueidentifier", nullable: true),
ComplexId = table.Column<int>(type: "int", nullable: true),
EventDate = table.Column<string>(type: "nvarchar(10)", maxLength: 10, nullable: false),
RegisterMobileNumber = table.Column<string>(type: "nvarchar(max)", nullable: false),
Body = table.Column<string>(type: "nvarchar(max)", nullable: false),
Description = table.Column<string>(type: "nvarchar(max)", nullable: true),
InsertTime = table.Column<DateTime>(type: "datetime2", nullable: false, defaultValue: new DateTime(2026, 6, 9, 2, 28, 45, 624, DateTimeKind.Local).AddTicks(5016)),
IsRemoved = table.Column<bool>(type: "bit", nullable: false, defaultValue: false),
RemoveTime = table.Column<DateTime>(type: "datetime2", nullable: true),
UpdateTime = table.Column<DateTime>(type: "datetime2", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_ComplexUnitEvents", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Persons",
columns: table => new
{
Id = table.Column<string>(type: "nvarchar(450)", nullable: false),
FirstName = table.Column<string>(type: "nvarchar(max)", nullable: true),
LastName = table.Column<string>(type: "nvarchar(max)", nullable: true),
Gender = table.Column<byte>(type: "tinyint", nullable: true),
Avatar = table.Column<byte[]>(type: "varbinary(max)", nullable: true),
IsActive = table.Column<bool>(type: "bit", nullable: false),
InsertTime = table.Column<DateTime>(type: "datetime2", nullable: false, defaultValue: new DateTime(2026, 6, 9, 2, 28, 45, 625, DateTimeKind.Local).AddTicks(1728)),
IsRemoved = table.Column<bool>(type: "bit", nullable: false, defaultValue: false),
RemoveTime = table.Column<DateTime>(type: "datetime2", nullable: true),
UpdateTime = table.Column<DateTime>(type: "datetime2", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Persons", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Posters",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
RegisterMobileNumber = table.Column<string>(type: "nvarchar(max)", nullable: false),
IsActive = table.Column<bool>(type: "bit", nullable: false),
ImagePath = table.Column<string>(type: "nvarchar(max)", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Posters", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Provinces",
columns: table => new
{
ProvinceId = table.Column<int>(type: "int", nullable: false),
ProvinceTitle = table.Column<string>(type: "nvarchar(max)", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Provinces", x => x.ProvinceId);
});
migrationBuilder.CreateTable(
name: "SmsCodes",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
PhoneNumber = table.Column<string>(type: "nvarchar(max)", nullable: false),
Code = table.Column<string>(type: "nvarchar(max)", nullable: false),
Used = table.Column<bool>(type: "bit", nullable: false),
RequestCount = table.Column<int>(type: "int", nullable: false),
InsertDate = table.Column<DateTime>(type: "datetime2", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_SmsCodes", x => x.Id);
});
migrationBuilder.CreateTable(
name: "UnitStates",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false),
ComplexId = table.Column<Guid>(type: "uniqueidentifier", nullable: true),
Title = table.Column<string>(type: "nvarchar(max)", nullable: false),
Icon = table.Column<string>(type: "nvarchar(max)", nullable: false),
InsertTime = table.Column<DateTime>(type: "datetime2", nullable: false, defaultValue: new DateTime(2026, 6, 9, 2, 28, 45, 626, DateTimeKind.Local).AddTicks(1646)),
IsRemoved = table.Column<bool>(type: "bit", nullable: false, defaultValue: false),
RemoveTime = table.Column<DateTime>(type: "datetime2", nullable: true),
UpdateTime = table.Column<DateTime>(type: "datetime2", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_UnitStates", x => x.Id);
});
migrationBuilder.CreateTable(
name: "ComplexPersons",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
ComplexId = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
PersonMobileNumberId = table.Column<string>(type: "nvarchar(450)", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_ComplexPersons", x => x.Id);
table.ForeignKey(
name: "FK_ComplexPersons_Persons_PersonMobileNumberId",
column: x => x.PersonMobileNumberId,
principalTable: "Persons",
principalColumn: "Id");
});
migrationBuilder.CreateTable(
name: "UserTokens",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
TokenHash = table.Column<string>(type: "nvarchar(max)", nullable: false),
TokenExp = table.Column<DateTime>(type: "datetime2", nullable: false),
RefreshToken = table.Column<string>(type: "nvarchar(max)", nullable: false),
RefreshTokenExp = table.Column<DateTime>(type: "datetime2", nullable: false),
MobileModel = table.Column<string>(type: "nvarchar(max)", nullable: false),
PersonId = table.Column<string>(type: "nvarchar(450)", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_UserTokens", x => x.Id);
table.ForeignKey(
name: "FK_UserTokens_Persons_PersonId",
column: x => x.PersonId,
principalTable: "Persons",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "Cities",
columns: table => new
{
CityId = table.Column<int>(type: "int", nullable: false),
ProvinceId = table.Column<int>(type: "int", nullable: true),
CityTitle = table.Column<string>(type: "nvarchar(max)", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Cities", x => x.CityId);
table.ForeignKey(
name: "FK_Cities_Provinces_ProvinceId",
column: x => x.ProvinceId,
principalTable: "Provinces",
principalColumn: "ProvinceId");
});
migrationBuilder.CreateTable(
name: "ComplexEntities",
columns: table => new
{
Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
Title = table.Column<string>(type: "nvarchar(max)", nullable: false),
Address = table.Column<string>(type: "nvarchar(max)", nullable: true),
StateId = table.Column<int>(type: "int", nullable: true),
AreaMeter = table.Column<int>(type: "int", nullable: true),
YardMeter = table.Column<int>(type: "int", nullable: true),
ElevatorCount = table.Column<int>(type: "int", nullable: true),
WarehouseCount = table.Column<int>(type: "int", nullable: true),
YearMake = table.Column<int>(type: "int", nullable: true),
ParentId = table.Column<Guid>(type: "uniqueidentifier", nullable: true),
Description = table.Column<string>(type: "nvarchar(max)", nullable: true),
CityId = table.Column<int>(type: "int", nullable: false),
InsertTime = table.Column<DateTime>(type: "datetime2", nullable: false, defaultValue: new DateTime(2026, 6, 9, 2, 28, 45, 623, DateTimeKind.Local).AddTicks(7632)),
IsRemoved = table.Column<bool>(type: "bit", nullable: false, defaultValue: false),
RemoveTime = table.Column<DateTime>(type: "datetime2", nullable: true),
UpdateTime = table.Column<DateTime>(type: "datetime2", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_ComplexEntities", x => x.Id);
table.ForeignKey(
name: "FK_ComplexEntities_Cities_CityId",
column: x => x.CityId,
principalTable: "Cities",
principalColumn: "CityId",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_ComplexEntities_ComplexEntities_ParentId",
column: x => x.ParentId,
principalTable: "ComplexEntities",
principalColumn: "Id");
});
migrationBuilder.CreateTable(
name: "ComplexManagers",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
ComplexId = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
ManagerMobileNumberId = table.Column<string>(type: "nvarchar(450)", nullable: true),
StartDate = table.Column<string>(type: "nvarchar(max)", nullable: false),
EndDate = table.Column<string>(type: "nvarchar(max)", nullable: false),
InsertTime = table.Column<DateTime>(type: "datetime2", nullable: false, defaultValue: new DateTime(2026, 6, 9, 2, 28, 45, 624, DateTimeKind.Local).AddTicks(2426)),
IsRemoved = table.Column<bool>(type: "bit", nullable: false, defaultValue: false),
RemoveTime = table.Column<DateTime>(type: "datetime2", nullable: true),
UpdateTime = table.Column<DateTime>(type: "datetime2", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_ComplexManagers", x => x.Id);
table.ForeignKey(
name: "FK_ComplexManagers_ComplexEntities_ComplexId",
column: x => x.ComplexId,
principalTable: "ComplexEntities",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_ComplexManagers_Persons_ManagerMobileNumberId",
column: x => x.ManagerMobileNumberId,
principalTable: "Persons",
principalColumn: "Id");
});
migrationBuilder.CreateTable(
name: "IncomeCostTitles",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false),
Title = table.Column<string>(type: "nvarchar(max)", nullable: true),
TransactionTypeId = table.Column<int>(type: "int", nullable: false),
ComplexId = table.Column<Guid>(type: "uniqueidentifier", nullable: true),
RegisterMobileNumber = table.Column<string>(type: "nvarchar(max)", nullable: true),
InsertTime = table.Column<DateTime>(type: "datetime2", nullable: false, defaultValue: new DateTime(2026, 6, 9, 2, 28, 45, 624, DateTimeKind.Local).AddTicks(9858)),
IsRemoved = table.Column<bool>(type: "bit", nullable: false, defaultValue: false),
RemoveTime = table.Column<DateTime>(type: "datetime2", nullable: true),
UpdateTime = table.Column<DateTime>(type: "datetime2", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_IncomeCostTitles", x => x.Id);
table.ForeignKey(
name: "FK_IncomeCostTitles_BasicTables_TransactionTypeId",
column: x => x.TransactionTypeId,
principalTable: "BasicTables",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_IncomeCostTitles_ComplexEntities_ComplexId",
column: x => x.ComplexId,
principalTable: "ComplexEntities",
principalColumn: "Id");
});
migrationBuilder.CreateTable(
name: "Units",
columns: table => new
{
Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
ComplexId = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
UnitName = table.Column<string>(type: "nvarchar(max)", nullable: false),
OwnerId = table.Column<string>(type: "nvarchar(450)", nullable: true),
TenantId = table.Column<string>(type: "nvarchar(450)", nullable: true),
IsActive = table.Column<bool>(type: "bit", nullable: false),
AreaMeter = table.Column<int>(type: "int", nullable: true),
EmergencyTels = table.Column<string>(type: "nvarchar(max)", nullable: true),
ParkingAreaMeter = table.Column<int>(type: "int", nullable: true),
YardMeter = table.Column<int>(type: "int", nullable: true),
PublicState = table.Column<string>(type: "nvarchar(max)", nullable: true),
StateId = table.Column<int>(type: "int", nullable: true),
Floor = table.Column<int>(type: "int", nullable: true),
ManagerDescription = table.Column<string>(type: "nvarchar(max)", nullable: true),
InsertTime = table.Column<DateTime>(type: "datetime2", nullable: false, defaultValue: new DateTime(2026, 6, 9, 2, 28, 45, 625, DateTimeKind.Local).AddTicks(7151)),
IsRemoved = table.Column<bool>(type: "bit", nullable: false, defaultValue: false),
RemoveTime = table.Column<DateTime>(type: "datetime2", nullable: true),
UpdateTime = table.Column<DateTime>(type: "datetime2", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Units", x => x.Id);
table.ForeignKey(
name: "FK_Units_ComplexEntities_ComplexId",
column: x => x.ComplexId,
principalTable: "ComplexEntities",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_Units_Persons_OwnerId",
column: x => x.OwnerId,
principalTable: "Persons",
principalColumn: "Id");
table.ForeignKey(
name: "FK_Units_Persons_TenantId",
column: x => x.TenantId,
principalTable: "Persons",
principalColumn: "Id");
table.ForeignKey(
name: "FK_Units_UnitStates_StateId",
column: x => x.StateId,
principalTable: "UnitStates",
principalColumn: "Id");
});
migrationBuilder.CreateTable(
name: "CostCycles",
columns: table => new
{
Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
ComplexId = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
Title = table.Column<string>(type: "nvarchar(max)", nullable: false),
StartDate = table.Column<DateTime>(type: "date", nullable: false),
EndDate = table.Column<DateTime>(type: "date", nullable: false),
Amount = table.Column<long>(type: "bigint", nullable: false),
EncouragementDay = table.Column<int>(type: "int", nullable: false),
EncouragementAmount = table.Column<long>(type: "bigint", nullable: false),
IncomeCostTitleId = table.Column<int>(type: "int", nullable: true),
InsertTime = table.Column<DateTime>(type: "datetime2", nullable: false, defaultValue: new DateTime(2026, 6, 9, 2, 28, 45, 624, DateTimeKind.Local).AddTicks(7249)),
IsRemoved = table.Column<bool>(type: "bit", nullable: false, defaultValue: false),
RemoveTime = table.Column<DateTime>(type: "datetime2", nullable: true),
UpdateTime = table.Column<DateTime>(type: "datetime2", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_CostCycles", x => x.Id);
table.ForeignKey(
name: "FK_CostCycles_ComplexEntities_ComplexId",
column: x => x.ComplexId,
principalTable: "ComplexEntities",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_CostCycles_IncomeCostTitles_IncomeCostTitleId",
column: x => x.IncomeCostTitleId,
principalTable: "IncomeCostTitles",
principalColumn: "Id");
});
migrationBuilder.CreateTable(
name: "CostCycleUnit",
columns: table => new
{
CostCyclesId = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
UnitsId = table.Column<Guid>(type: "uniqueidentifier", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_CostCycleUnit", x => new { x.CostCyclesId, x.UnitsId });
table.ForeignKey(
name: "FK_CostCycleUnit_CostCycles_CostCyclesId",
column: x => x.CostCyclesId,
principalTable: "CostCycles",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_CostCycleUnit_Units_UnitsId",
column: x => x.UnitsId,
principalTable: "Units",
principalColumn: "Id");
});
migrationBuilder.CreateTable(
name: "UnitCosts",
columns: table => new
{
Id = table.Column<long>(type: "bigint", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
CostCycleId = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
UnitId = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
TransactionId = table.Column<int>(type: "int", nullable: true),
Date = table.Column<DateTime>(type: "date", nullable: false),
InsertTime = table.Column<DateTime>(type: "datetime2", nullable: false, defaultValue: new DateTime(2026, 6, 9, 2, 28, 45, 625, DateTimeKind.Local).AddTicks(9764)),
IsRemoved = table.Column<bool>(type: "bit", nullable: false, defaultValue: false),
RemoveTime = table.Column<DateTime>(type: "datetime2", nullable: true),
UpdateTime = table.Column<DateTime>(type: "datetime2", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_UnitCosts", x => x.Id);
table.ForeignKey(
name: "FK_UnitCosts_CostCycles_CostCycleId",
column: x => x.CostCycleId,
principalTable: "CostCycles",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_UnitCosts_Units_UnitId",
column: x => x.UnitId,
principalTable: "Units",
principalColumn: "Id");
});
migrationBuilder.CreateTable(
name: "Transactions",
columns: table => new
{
Id = table.Column<long>(type: "bigint", nullable: false),
TransactionTitleId = table.Column<int>(type: "int", nullable: true),
TransactionPersianDate = table.Column<string>(type: "nvarchar(10)", maxLength: 10, nullable: false),
TransactionDate = table.Column<DateTime>(type: "datetime2", nullable: false),
Amount = table.Column<long>(type: "bigint", nullable: false),
Description = table.Column<string>(type: "nvarchar(max)", nullable: true),
CostCycleId = table.Column<Guid>(type: "uniqueidentifier", nullable: true),
UnitId = table.Column<Guid>(type: "uniqueidentifier", nullable: true),
FicheId = table.Column<string>(type: "nvarchar(max)", nullable: true),
ComplexId = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
UnitCostId = table.Column<long>(type: "bigint", nullable: false),
PersonId = table.Column<string>(type: "nvarchar(450)", nullable: false),
InsertTime = table.Column<DateTime>(type: "datetime2", nullable: false, defaultValue: new DateTime(2026, 6, 9, 2, 28, 45, 625, DateTimeKind.Local).AddTicks(3921)),
IsRemoved = table.Column<bool>(type: "bit", nullable: false, defaultValue: false),
RemoveTime = table.Column<DateTime>(type: "datetime2", nullable: true),
UpdateTime = table.Column<DateTime>(type: "datetime2", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Transactions", x => x.Id);
table.ForeignKey(
name: "FK_Transactions_CostCycles_CostCycleId",
column: x => x.CostCycleId,
principalTable: "CostCycles",
principalColumn: "Id");
table.ForeignKey(
name: "FK_Transactions_IncomeCostTitles_TransactionTitleId",
column: x => x.TransactionTitleId,
principalTable: "IncomeCostTitles",
principalColumn: "Id");
table.ForeignKey(
name: "FK_Transactions_Persons_PersonId",
column: x => x.PersonId,
principalTable: "Persons",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_Transactions_UnitCosts_UnitCostId",
column: x => x.UnitCostId,
principalTable: "UnitCosts",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_Transactions_Units_UnitId",
column: x => x.UnitId,
principalTable: "Units",
principalColumn: "Id");
});
migrationBuilder.CreateIndex(
name: "IX_Cities_ProvinceId",
table: "Cities",
column: "ProvinceId");
migrationBuilder.CreateIndex(
name: "IX_ComplexEntities_CityId",
table: "ComplexEntities",
column: "CityId");
migrationBuilder.CreateIndex(
name: "IX_ComplexEntities_ParentId",
table: "ComplexEntities",
column: "ParentId");
migrationBuilder.CreateIndex(
name: "IX_ComplexManagers_ComplexId",
table: "ComplexManagers",
column: "ComplexId");
migrationBuilder.CreateIndex(
name: "IX_ComplexManagers_ManagerMobileNumberId",
table: "ComplexManagers",
column: "ManagerMobileNumberId");
migrationBuilder.CreateIndex(
name: "IX_ComplexPersons_PersonMobileNumberId",
table: "ComplexPersons",
column: "PersonMobileNumberId");
migrationBuilder.CreateIndex(
name: "IX_CostCycles_ComplexId",
table: "CostCycles",
column: "ComplexId");
migrationBuilder.CreateIndex(
name: "IX_CostCycles_IncomeCostTitleId",
table: "CostCycles",
column: "IncomeCostTitleId");
migrationBuilder.CreateIndex(
name: "IX_CostCycleUnit_UnitsId",
table: "CostCycleUnit",
column: "UnitsId");
migrationBuilder.CreateIndex(
name: "IX_IncomeCostTitles_ComplexId",
table: "IncomeCostTitles",
column: "ComplexId");
migrationBuilder.CreateIndex(
name: "IX_IncomeCostTitles_TransactionTypeId",
table: "IncomeCostTitles",
column: "TransactionTypeId");
migrationBuilder.CreateIndex(
name: "IX_Transactions_CostCycleId",
table: "Transactions",
column: "CostCycleId");
migrationBuilder.CreateIndex(
name: "IX_Transactions_PersonId",
table: "Transactions",
column: "PersonId");
migrationBuilder.CreateIndex(
name: "IX_Transactions_TransactionTitleId",
table: "Transactions",
column: "TransactionTitleId");
migrationBuilder.CreateIndex(
name: "IX_Transactions_UnitCostId",
table: "Transactions",
column: "UnitCostId",
unique: true);
migrationBuilder.CreateIndex(
name: "IX_Transactions_UnitId",
table: "Transactions",
column: "UnitId");
migrationBuilder.CreateIndex(
name: "IX_UnitCosts_CostCycleId",
table: "UnitCosts",
column: "CostCycleId");
migrationBuilder.CreateIndex(
name: "IX_UnitCosts_UnitId",
table: "UnitCosts",
column: "UnitId");
migrationBuilder.CreateIndex(
name: "IX_Units_ComplexId",
table: "Units",
column: "ComplexId");
migrationBuilder.CreateIndex(
name: "IX_Units_OwnerId",
table: "Units",
column: "OwnerId");
migrationBuilder.CreateIndex(
name: "IX_Units_StateId",
table: "Units",
column: "StateId");
migrationBuilder.CreateIndex(
name: "IX_Units_TenantId",
table: "Units",
column: "TenantId");
migrationBuilder.CreateIndex(
name: "IX_UserTokens_PersonId",
table: "UserTokens",
column: "PersonId");
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "Chats");
migrationBuilder.DropTable(
name: "ComplexManagers");
migrationBuilder.DropTable(
name: "ComplexPersons");
migrationBuilder.DropTable(
name: "ComplexUnitEvents");
migrationBuilder.DropTable(
name: "CostCycleUnit");
migrationBuilder.DropTable(
name: "Posters");
migrationBuilder.DropTable(
name: "SmsCodes");
migrationBuilder.DropTable(
name: "Transactions");
migrationBuilder.DropTable(
name: "UserTokens");
migrationBuilder.DropTable(
name: "UnitCosts");
migrationBuilder.DropTable(
name: "CostCycles");
migrationBuilder.DropTable(
name: "Units");
migrationBuilder.DropTable(
name: "IncomeCostTitles");
migrationBuilder.DropTable(
name: "Persons");
migrationBuilder.DropTable(
name: "UnitStates");
migrationBuilder.DropTable(
name: "BasicTables");
migrationBuilder.DropTable(
name: "ComplexEntities");
migrationBuilder.DropTable(
name: "Cities");
migrationBuilder.DropTable(
name: "Provinces");
}
}
}

View File

@@ -12,8 +12,8 @@ using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
namespace Complex.Infrastructure.Migrations
{
[DbContext(typeof(ComplexDBContext))]
[Migration("20250601024740_add-complexPerson")]
partial class addcomplexPerson
[Migration("20260611161156_AddAuditableToChat")]
partial class AddAuditableToChat
{
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
@@ -27,11 +27,8 @@ namespace Complex.Infrastructure.Migrations
modelBuilder.Entity("Complex.Domain.Entities.BasicTable", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"), 1L, 1);
b.Property<string>("Discriminator")
.IsRequired()
.HasColumnType("nvarchar(max)");
@@ -65,10 +62,26 @@ namespace Complex.Infrastructure.Migrations
b.Property<Guid>("ComplexId")
.HasColumnType("uniqueidentifier");
b.Property<DateTime>("InsertTime")
.ValueGeneratedOnAdd()
.HasColumnType("datetime2")
.HasDefaultValue(new DateTime(2026, 6, 11, 19, 41, 56, 678, DateTimeKind.Local).AddTicks(4132));
b.Property<bool>("IsRemoved")
.ValueGeneratedOnAdd()
.HasColumnType("bit")
.HasDefaultValue(false);
b.Property<string>("PersonMobileNumber")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<DateTime?>("RemoveTime")
.HasColumnType("datetime2");
b.Property<DateTime?>("UpdateTime")
.HasColumnType("datetime2");
b.HasKey("Id");
b.ToTable("Chats");
@@ -77,11 +90,8 @@ namespace Complex.Infrastructure.Migrations
modelBuilder.Entity("Complex.Domain.Entities.City", b =>
{
b.Property<int>("CityId")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("CityId"), 1L, 1);
b.Property<string>("CityTitle")
.HasColumnType("nvarchar(max)");
@@ -92,7 +102,7 @@ namespace Complex.Infrastructure.Migrations
b.HasIndex("ProvinceId");
b.ToTable("City");
b.ToTable("Cities");
});
modelBuilder.Entity("Complex.Domain.Entities.ComplexEntity", b =>
@@ -119,7 +129,7 @@ namespace Complex.Infrastructure.Migrations
b.Property<DateTime>("InsertTime")
.ValueGeneratedOnAdd()
.HasColumnType("datetime2")
.HasDefaultValue(new DateTime(2025, 6, 1, 6, 17, 40, 42, DateTimeKind.Local).AddTicks(207));
.HasDefaultValue(new DateTime(2026, 6, 11, 19, 41, 56, 678, DateTimeKind.Local).AddTicks(7208));
b.Property<bool>("IsRemoved")
.ValueGeneratedOnAdd()
@@ -178,7 +188,7 @@ namespace Complex.Infrastructure.Migrations
b.Property<DateTime>("InsertTime")
.ValueGeneratedOnAdd()
.HasColumnType("datetime2")
.HasDefaultValue(new DateTime(2025, 6, 1, 6, 17, 40, 42, DateTimeKind.Local).AddTicks(2979));
.HasDefaultValue(new DateTime(2026, 6, 11, 19, 41, 56, 678, DateTimeKind.Local).AddTicks(9914));
b.Property<bool>("IsRemoved")
.ValueGeneratedOnAdd()
@@ -254,7 +264,7 @@ namespace Complex.Infrastructure.Migrations
b.Property<DateTime>("InsertTime")
.ValueGeneratedOnAdd()
.HasColumnType("datetime2")
.HasDefaultValue(new DateTime(2025, 6, 1, 6, 17, 40, 42, DateTimeKind.Local).AddTicks(4581));
.HasDefaultValue(new DateTime(2026, 6, 11, 19, 41, 56, 679, DateTimeKind.Local).AddTicks(795));
b.Property<bool>("IsRemoved")
.ValueGeneratedOnAdd()
@@ -306,7 +316,7 @@ namespace Complex.Infrastructure.Migrations
b.Property<DateTime>("InsertTime")
.ValueGeneratedOnAdd()
.HasColumnType("datetime2")
.HasDefaultValue(new DateTime(2025, 6, 1, 6, 17, 40, 42, DateTimeKind.Local).AddTicks(6075));
.HasDefaultValue(new DateTime(2026, 6, 11, 19, 41, 56, 679, DateTimeKind.Local).AddTicks(1849));
b.Property<bool>("IsRemoved")
.ValueGeneratedOnAdd()
@@ -338,18 +348,15 @@ namespace Complex.Infrastructure.Migrations
modelBuilder.Entity("Complex.Domain.Entities.IncomeCostTitle", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"), 1L, 1);
b.Property<Guid?>("ComplexId")
.HasColumnType("uniqueidentifier");
b.Property<DateTime>("InsertTime")
.ValueGeneratedOnAdd()
.HasColumnType("datetime2")
.HasDefaultValue(new DateTime(2025, 6, 1, 6, 17, 40, 42, DateTimeKind.Local).AddTicks(8706));
.HasDefaultValue(new DateTime(2026, 6, 11, 19, 41, 56, 679, DateTimeKind.Local).AddTicks(3528));
b.Property<bool>("IsRemoved")
.ValueGeneratedOnAdd()
@@ -397,7 +404,7 @@ namespace Complex.Infrastructure.Migrations
b.Property<DateTime>("InsertTime")
.ValueGeneratedOnAdd()
.HasColumnType("datetime2")
.HasDefaultValue(new DateTime(2025, 6, 1, 6, 17, 40, 43, DateTimeKind.Local).AddTicks(1127));
.HasDefaultValue(new DateTime(2026, 6, 11, 19, 41, 56, 679, DateTimeKind.Local).AddTicks(5645));
b.Property<bool>("IsActive")
.HasColumnType("bit");
@@ -448,17 +455,14 @@ namespace Complex.Infrastructure.Migrations
modelBuilder.Entity("Complex.Domain.Entities.Province", b =>
{
b.Property<int>("ProvinceId")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("ProvinceId"), 1L, 1);
b.Property<string>("ProvinceTitle")
.HasColumnType("nvarchar(max)");
b.HasKey("ProvinceId");
b.ToTable("Province");
b.ToTable("Provinces");
});
modelBuilder.Entity("Complex.Domain.Entities.SmsCode", b =>
@@ -494,11 +498,8 @@ namespace Complex.Infrastructure.Migrations
modelBuilder.Entity("Complex.Domain.Entities.Transaction", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("bigint");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<long>("Id"), 1L, 1);
b.Property<long>("Amount")
.HasColumnType("bigint");
@@ -517,7 +518,7 @@ namespace Complex.Infrastructure.Migrations
b.Property<DateTime>("InsertTime")
.ValueGeneratedOnAdd()
.HasColumnType("datetime2")
.HasDefaultValue(new DateTime(2025, 6, 1, 6, 17, 40, 43, DateTimeKind.Local).AddTicks(3798));
.HasDefaultValue(new DateTime(2026, 6, 11, 19, 41, 56, 679, DateTimeKind.Local).AddTicks(7492));
b.Property<bool>("IsRemoved")
.ValueGeneratedOnAdd()
@@ -588,7 +589,7 @@ namespace Complex.Infrastructure.Migrations
b.Property<DateTime>("InsertTime")
.ValueGeneratedOnAdd()
.HasColumnType("datetime2")
.HasDefaultValue(new DateTime(2025, 6, 1, 6, 17, 40, 43, DateTimeKind.Local).AddTicks(7020));
.HasDefaultValue(new DateTime(2026, 6, 11, 19, 41, 56, 679, DateTimeKind.Local).AddTicks(9506));
b.Property<bool>("IsActive")
.HasColumnType("bit");
@@ -659,7 +660,7 @@ namespace Complex.Infrastructure.Migrations
b.Property<DateTime>("InsertTime")
.ValueGeneratedOnAdd()
.HasColumnType("datetime2")
.HasDefaultValue(new DateTime(2025, 6, 1, 6, 17, 40, 44, DateTimeKind.Local).AddTicks(118));
.HasDefaultValue(new DateTime(2026, 6, 11, 19, 41, 56, 680, DateTimeKind.Local).AddTicks(1537));
b.Property<bool>("IsRemoved")
.ValueGeneratedOnAdd()
@@ -690,11 +691,8 @@ namespace Complex.Infrastructure.Migrations
modelBuilder.Entity("Complex.Domain.Entities.UnitState", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"), 1L, 1);
b.Property<Guid?>("ComplexId")
.HasColumnType("uniqueidentifier");
@@ -705,7 +703,7 @@ namespace Complex.Infrastructure.Migrations
b.Property<DateTime>("InsertTime")
.ValueGeneratedOnAdd()
.HasColumnType("datetime2")
.HasDefaultValue(new DateTime(2025, 6, 1, 6, 17, 40, 44, DateTimeKind.Local).AddTicks(2122));
.HasDefaultValue(new DateTime(2026, 6, 11, 19, 41, 56, 680, DateTimeKind.Local).AddTicks(2670));
b.Property<bool>("IsRemoved")
.ValueGeneratedOnAdd()
@@ -949,7 +947,7 @@ namespace Complex.Infrastructure.Migrations
b.HasOne("Complex.Domain.Entities.Unit", "Unit")
.WithMany()
.HasForeignKey("UnitId")
.OnDelete(DeleteBehavior.Cascade)
.OnDelete(DeleteBehavior.NoAction)
.IsRequired();
b.Navigation("CostCycle");
@@ -979,7 +977,7 @@ namespace Complex.Infrastructure.Migrations
b.HasOne("Complex.Domain.Entities.Unit", null)
.WithMany()
.HasForeignKey("UnitsId")
.OnDelete(DeleteBehavior.Cascade)
.OnDelete(DeleteBehavior.NoAction)
.IsRequired();
});

View File

@@ -0,0 +1,258 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Complex.Infrastructure.Migrations
{
public partial class AddAuditableToChat : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AlterColumn<DateTime>(
name: "InsertTime",
table: "UnitStates",
type: "datetime2",
nullable: false,
defaultValue: new DateTime(2026, 6, 11, 19, 41, 56, 680, DateTimeKind.Local).AddTicks(2670),
oldClrType: typeof(DateTime),
oldType: "datetime2",
oldDefaultValue: new DateTime(2026, 6, 9, 2, 28, 45, 626, DateTimeKind.Local).AddTicks(1646));
migrationBuilder.AlterColumn<DateTime>(
name: "InsertTime",
table: "Units",
type: "datetime2",
nullable: false,
defaultValue: new DateTime(2026, 6, 11, 19, 41, 56, 679, DateTimeKind.Local).AddTicks(9506),
oldClrType: typeof(DateTime),
oldType: "datetime2",
oldDefaultValue: new DateTime(2026, 6, 9, 2, 28, 45, 625, DateTimeKind.Local).AddTicks(7151));
migrationBuilder.AlterColumn<DateTime>(
name: "InsertTime",
table: "UnitCosts",
type: "datetime2",
nullable: false,
defaultValue: new DateTime(2026, 6, 11, 19, 41, 56, 680, DateTimeKind.Local).AddTicks(1537),
oldClrType: typeof(DateTime),
oldType: "datetime2",
oldDefaultValue: new DateTime(2026, 6, 9, 2, 28, 45, 625, DateTimeKind.Local).AddTicks(9764));
migrationBuilder.AlterColumn<DateTime>(
name: "InsertTime",
table: "Transactions",
type: "datetime2",
nullable: false,
defaultValue: new DateTime(2026, 6, 11, 19, 41, 56, 679, DateTimeKind.Local).AddTicks(7492),
oldClrType: typeof(DateTime),
oldType: "datetime2",
oldDefaultValue: new DateTime(2026, 6, 9, 2, 28, 45, 625, DateTimeKind.Local).AddTicks(3921));
migrationBuilder.AlterColumn<DateTime>(
name: "InsertTime",
table: "Persons",
type: "datetime2",
nullable: false,
defaultValue: new DateTime(2026, 6, 11, 19, 41, 56, 679, DateTimeKind.Local).AddTicks(5645),
oldClrType: typeof(DateTime),
oldType: "datetime2",
oldDefaultValue: new DateTime(2026, 6, 9, 2, 28, 45, 625, DateTimeKind.Local).AddTicks(1728));
migrationBuilder.AlterColumn<DateTime>(
name: "InsertTime",
table: "IncomeCostTitles",
type: "datetime2",
nullable: false,
defaultValue: new DateTime(2026, 6, 11, 19, 41, 56, 679, DateTimeKind.Local).AddTicks(3528),
oldClrType: typeof(DateTime),
oldType: "datetime2",
oldDefaultValue: new DateTime(2026, 6, 9, 2, 28, 45, 624, DateTimeKind.Local).AddTicks(9858));
migrationBuilder.AlterColumn<DateTime>(
name: "InsertTime",
table: "CostCycles",
type: "datetime2",
nullable: false,
defaultValue: new DateTime(2026, 6, 11, 19, 41, 56, 679, DateTimeKind.Local).AddTicks(1849),
oldClrType: typeof(DateTime),
oldType: "datetime2",
oldDefaultValue: new DateTime(2026, 6, 9, 2, 28, 45, 624, DateTimeKind.Local).AddTicks(7249));
migrationBuilder.AlterColumn<DateTime>(
name: "InsertTime",
table: "ComplexUnitEvents",
type: "datetime2",
nullable: false,
defaultValue: new DateTime(2026, 6, 11, 19, 41, 56, 679, DateTimeKind.Local).AddTicks(795),
oldClrType: typeof(DateTime),
oldType: "datetime2",
oldDefaultValue: new DateTime(2026, 6, 9, 2, 28, 45, 624, DateTimeKind.Local).AddTicks(5016));
migrationBuilder.AlterColumn<DateTime>(
name: "InsertTime",
table: "ComplexManagers",
type: "datetime2",
nullable: false,
defaultValue: new DateTime(2026, 6, 11, 19, 41, 56, 678, DateTimeKind.Local).AddTicks(9914),
oldClrType: typeof(DateTime),
oldType: "datetime2",
oldDefaultValue: new DateTime(2026, 6, 9, 2, 28, 45, 624, DateTimeKind.Local).AddTicks(2426));
migrationBuilder.AlterColumn<DateTime>(
name: "InsertTime",
table: "ComplexEntities",
type: "datetime2",
nullable: false,
defaultValue: new DateTime(2026, 6, 11, 19, 41, 56, 678, DateTimeKind.Local).AddTicks(7208),
oldClrType: typeof(DateTime),
oldType: "datetime2",
oldDefaultValue: new DateTime(2026, 6, 9, 2, 28, 45, 623, DateTimeKind.Local).AddTicks(7632));
migrationBuilder.AddColumn<DateTime>(
name: "InsertTime",
table: "Chats",
type: "datetime2",
nullable: false,
defaultValue: new DateTime(2026, 6, 11, 19, 41, 56, 678, DateTimeKind.Local).AddTicks(4132));
migrationBuilder.AddColumn<bool>(
name: "IsRemoved",
table: "Chats",
type: "bit",
nullable: false,
defaultValue: false);
migrationBuilder.AddColumn<DateTime>(
name: "RemoveTime",
table: "Chats",
type: "datetime2",
nullable: true);
migrationBuilder.AddColumn<DateTime>(
name: "UpdateTime",
table: "Chats",
type: "datetime2",
nullable: true);
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "InsertTime",
table: "Chats");
migrationBuilder.DropColumn(
name: "IsRemoved",
table: "Chats");
migrationBuilder.DropColumn(
name: "RemoveTime",
table: "Chats");
migrationBuilder.DropColumn(
name: "UpdateTime",
table: "Chats");
migrationBuilder.AlterColumn<DateTime>(
name: "InsertTime",
table: "UnitStates",
type: "datetime2",
nullable: false,
defaultValue: new DateTime(2026, 6, 9, 2, 28, 45, 626, DateTimeKind.Local).AddTicks(1646),
oldClrType: typeof(DateTime),
oldType: "datetime2",
oldDefaultValue: new DateTime(2026, 6, 11, 19, 41, 56, 680, DateTimeKind.Local).AddTicks(2670));
migrationBuilder.AlterColumn<DateTime>(
name: "InsertTime",
table: "Units",
type: "datetime2",
nullable: false,
defaultValue: new DateTime(2026, 6, 9, 2, 28, 45, 625, DateTimeKind.Local).AddTicks(7151),
oldClrType: typeof(DateTime),
oldType: "datetime2",
oldDefaultValue: new DateTime(2026, 6, 11, 19, 41, 56, 679, DateTimeKind.Local).AddTicks(9506));
migrationBuilder.AlterColumn<DateTime>(
name: "InsertTime",
table: "UnitCosts",
type: "datetime2",
nullable: false,
defaultValue: new DateTime(2026, 6, 9, 2, 28, 45, 625, DateTimeKind.Local).AddTicks(9764),
oldClrType: typeof(DateTime),
oldType: "datetime2",
oldDefaultValue: new DateTime(2026, 6, 11, 19, 41, 56, 680, DateTimeKind.Local).AddTicks(1537));
migrationBuilder.AlterColumn<DateTime>(
name: "InsertTime",
table: "Transactions",
type: "datetime2",
nullable: false,
defaultValue: new DateTime(2026, 6, 9, 2, 28, 45, 625, DateTimeKind.Local).AddTicks(3921),
oldClrType: typeof(DateTime),
oldType: "datetime2",
oldDefaultValue: new DateTime(2026, 6, 11, 19, 41, 56, 679, DateTimeKind.Local).AddTicks(7492));
migrationBuilder.AlterColumn<DateTime>(
name: "InsertTime",
table: "Persons",
type: "datetime2",
nullable: false,
defaultValue: new DateTime(2026, 6, 9, 2, 28, 45, 625, DateTimeKind.Local).AddTicks(1728),
oldClrType: typeof(DateTime),
oldType: "datetime2",
oldDefaultValue: new DateTime(2026, 6, 11, 19, 41, 56, 679, DateTimeKind.Local).AddTicks(5645));
migrationBuilder.AlterColumn<DateTime>(
name: "InsertTime",
table: "IncomeCostTitles",
type: "datetime2",
nullable: false,
defaultValue: new DateTime(2026, 6, 9, 2, 28, 45, 624, DateTimeKind.Local).AddTicks(9858),
oldClrType: typeof(DateTime),
oldType: "datetime2",
oldDefaultValue: new DateTime(2026, 6, 11, 19, 41, 56, 679, DateTimeKind.Local).AddTicks(3528));
migrationBuilder.AlterColumn<DateTime>(
name: "InsertTime",
table: "CostCycles",
type: "datetime2",
nullable: false,
defaultValue: new DateTime(2026, 6, 9, 2, 28, 45, 624, DateTimeKind.Local).AddTicks(7249),
oldClrType: typeof(DateTime),
oldType: "datetime2",
oldDefaultValue: new DateTime(2026, 6, 11, 19, 41, 56, 679, DateTimeKind.Local).AddTicks(1849));
migrationBuilder.AlterColumn<DateTime>(
name: "InsertTime",
table: "ComplexUnitEvents",
type: "datetime2",
nullable: false,
defaultValue: new DateTime(2026, 6, 9, 2, 28, 45, 624, DateTimeKind.Local).AddTicks(5016),
oldClrType: typeof(DateTime),
oldType: "datetime2",
oldDefaultValue: new DateTime(2026, 6, 11, 19, 41, 56, 679, DateTimeKind.Local).AddTicks(795));
migrationBuilder.AlterColumn<DateTime>(
name: "InsertTime",
table: "ComplexManagers",
type: "datetime2",
nullable: false,
defaultValue: new DateTime(2026, 6, 9, 2, 28, 45, 624, DateTimeKind.Local).AddTicks(2426),
oldClrType: typeof(DateTime),
oldType: "datetime2",
oldDefaultValue: new DateTime(2026, 6, 11, 19, 41, 56, 678, DateTimeKind.Local).AddTicks(9914));
migrationBuilder.AlterColumn<DateTime>(
name: "InsertTime",
table: "ComplexEntities",
type: "datetime2",
nullable: false,
defaultValue: new DateTime(2026, 6, 9, 2, 28, 45, 623, DateTimeKind.Local).AddTicks(7632),
oldClrType: typeof(DateTime),
oldType: "datetime2",
oldDefaultValue: new DateTime(2026, 6, 11, 19, 41, 56, 678, DateTimeKind.Local).AddTicks(7208));
}
}
}

View File

@@ -25,11 +25,8 @@ namespace Complex.Infrastructure.Migrations
modelBuilder.Entity("Complex.Domain.Entities.BasicTable", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"), 1L, 1);
b.Property<string>("Discriminator")
.IsRequired()
.HasColumnType("nvarchar(max)");
@@ -63,10 +60,26 @@ namespace Complex.Infrastructure.Migrations
b.Property<Guid>("ComplexId")
.HasColumnType("uniqueidentifier");
b.Property<DateTime>("InsertTime")
.ValueGeneratedOnAdd()
.HasColumnType("datetime2")
.HasDefaultValue(new DateTime(2026, 6, 11, 19, 41, 56, 678, DateTimeKind.Local).AddTicks(4132));
b.Property<bool>("IsRemoved")
.ValueGeneratedOnAdd()
.HasColumnType("bit")
.HasDefaultValue(false);
b.Property<string>("PersonMobileNumber")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<DateTime?>("RemoveTime")
.HasColumnType("datetime2");
b.Property<DateTime?>("UpdateTime")
.HasColumnType("datetime2");
b.HasKey("Id");
b.ToTable("Chats");
@@ -75,11 +88,8 @@ namespace Complex.Infrastructure.Migrations
modelBuilder.Entity("Complex.Domain.Entities.City", b =>
{
b.Property<int>("CityId")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("CityId"), 1L, 1);
b.Property<string>("CityTitle")
.HasColumnType("nvarchar(max)");
@@ -90,7 +100,7 @@ namespace Complex.Infrastructure.Migrations
b.HasIndex("ProvinceId");
b.ToTable("City");
b.ToTable("Cities");
});
modelBuilder.Entity("Complex.Domain.Entities.ComplexEntity", b =>
@@ -117,7 +127,7 @@ namespace Complex.Infrastructure.Migrations
b.Property<DateTime>("InsertTime")
.ValueGeneratedOnAdd()
.HasColumnType("datetime2")
.HasDefaultValue(new DateTime(2025, 6, 1, 6, 17, 40, 42, DateTimeKind.Local).AddTicks(207));
.HasDefaultValue(new DateTime(2026, 6, 11, 19, 41, 56, 678, DateTimeKind.Local).AddTicks(7208));
b.Property<bool>("IsRemoved")
.ValueGeneratedOnAdd()
@@ -176,7 +186,7 @@ namespace Complex.Infrastructure.Migrations
b.Property<DateTime>("InsertTime")
.ValueGeneratedOnAdd()
.HasColumnType("datetime2")
.HasDefaultValue(new DateTime(2025, 6, 1, 6, 17, 40, 42, DateTimeKind.Local).AddTicks(2979));
.HasDefaultValue(new DateTime(2026, 6, 11, 19, 41, 56, 678, DateTimeKind.Local).AddTicks(9914));
b.Property<bool>("IsRemoved")
.ValueGeneratedOnAdd()
@@ -252,7 +262,7 @@ namespace Complex.Infrastructure.Migrations
b.Property<DateTime>("InsertTime")
.ValueGeneratedOnAdd()
.HasColumnType("datetime2")
.HasDefaultValue(new DateTime(2025, 6, 1, 6, 17, 40, 42, DateTimeKind.Local).AddTicks(4581));
.HasDefaultValue(new DateTime(2026, 6, 11, 19, 41, 56, 679, DateTimeKind.Local).AddTicks(795));
b.Property<bool>("IsRemoved")
.ValueGeneratedOnAdd()
@@ -304,7 +314,7 @@ namespace Complex.Infrastructure.Migrations
b.Property<DateTime>("InsertTime")
.ValueGeneratedOnAdd()
.HasColumnType("datetime2")
.HasDefaultValue(new DateTime(2025, 6, 1, 6, 17, 40, 42, DateTimeKind.Local).AddTicks(6075));
.HasDefaultValue(new DateTime(2026, 6, 11, 19, 41, 56, 679, DateTimeKind.Local).AddTicks(1849));
b.Property<bool>("IsRemoved")
.ValueGeneratedOnAdd()
@@ -336,18 +346,15 @@ namespace Complex.Infrastructure.Migrations
modelBuilder.Entity("Complex.Domain.Entities.IncomeCostTitle", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"), 1L, 1);
b.Property<Guid?>("ComplexId")
.HasColumnType("uniqueidentifier");
b.Property<DateTime>("InsertTime")
.ValueGeneratedOnAdd()
.HasColumnType("datetime2")
.HasDefaultValue(new DateTime(2025, 6, 1, 6, 17, 40, 42, DateTimeKind.Local).AddTicks(8706));
.HasDefaultValue(new DateTime(2026, 6, 11, 19, 41, 56, 679, DateTimeKind.Local).AddTicks(3528));
b.Property<bool>("IsRemoved")
.ValueGeneratedOnAdd()
@@ -395,7 +402,7 @@ namespace Complex.Infrastructure.Migrations
b.Property<DateTime>("InsertTime")
.ValueGeneratedOnAdd()
.HasColumnType("datetime2")
.HasDefaultValue(new DateTime(2025, 6, 1, 6, 17, 40, 43, DateTimeKind.Local).AddTicks(1127));
.HasDefaultValue(new DateTime(2026, 6, 11, 19, 41, 56, 679, DateTimeKind.Local).AddTicks(5645));
b.Property<bool>("IsActive")
.HasColumnType("bit");
@@ -446,17 +453,14 @@ namespace Complex.Infrastructure.Migrations
modelBuilder.Entity("Complex.Domain.Entities.Province", b =>
{
b.Property<int>("ProvinceId")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("ProvinceId"), 1L, 1);
b.Property<string>("ProvinceTitle")
.HasColumnType("nvarchar(max)");
b.HasKey("ProvinceId");
b.ToTable("Province");
b.ToTable("Provinces");
});
modelBuilder.Entity("Complex.Domain.Entities.SmsCode", b =>
@@ -492,11 +496,8 @@ namespace Complex.Infrastructure.Migrations
modelBuilder.Entity("Complex.Domain.Entities.Transaction", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("bigint");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<long>("Id"), 1L, 1);
b.Property<long>("Amount")
.HasColumnType("bigint");
@@ -515,7 +516,7 @@ namespace Complex.Infrastructure.Migrations
b.Property<DateTime>("InsertTime")
.ValueGeneratedOnAdd()
.HasColumnType("datetime2")
.HasDefaultValue(new DateTime(2025, 6, 1, 6, 17, 40, 43, DateTimeKind.Local).AddTicks(3798));
.HasDefaultValue(new DateTime(2026, 6, 11, 19, 41, 56, 679, DateTimeKind.Local).AddTicks(7492));
b.Property<bool>("IsRemoved")
.ValueGeneratedOnAdd()
@@ -586,7 +587,7 @@ namespace Complex.Infrastructure.Migrations
b.Property<DateTime>("InsertTime")
.ValueGeneratedOnAdd()
.HasColumnType("datetime2")
.HasDefaultValue(new DateTime(2025, 6, 1, 6, 17, 40, 43, DateTimeKind.Local).AddTicks(7020));
.HasDefaultValue(new DateTime(2026, 6, 11, 19, 41, 56, 679, DateTimeKind.Local).AddTicks(9506));
b.Property<bool>("IsActive")
.HasColumnType("bit");
@@ -657,7 +658,7 @@ namespace Complex.Infrastructure.Migrations
b.Property<DateTime>("InsertTime")
.ValueGeneratedOnAdd()
.HasColumnType("datetime2")
.HasDefaultValue(new DateTime(2025, 6, 1, 6, 17, 40, 44, DateTimeKind.Local).AddTicks(118));
.HasDefaultValue(new DateTime(2026, 6, 11, 19, 41, 56, 680, DateTimeKind.Local).AddTicks(1537));
b.Property<bool>("IsRemoved")
.ValueGeneratedOnAdd()
@@ -688,11 +689,8 @@ namespace Complex.Infrastructure.Migrations
modelBuilder.Entity("Complex.Domain.Entities.UnitState", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"), 1L, 1);
b.Property<Guid?>("ComplexId")
.HasColumnType("uniqueidentifier");
@@ -703,7 +701,7 @@ namespace Complex.Infrastructure.Migrations
b.Property<DateTime>("InsertTime")
.ValueGeneratedOnAdd()
.HasColumnType("datetime2")
.HasDefaultValue(new DateTime(2025, 6, 1, 6, 17, 40, 44, DateTimeKind.Local).AddTicks(2122));
.HasDefaultValue(new DateTime(2026, 6, 11, 19, 41, 56, 680, DateTimeKind.Local).AddTicks(2670));
b.Property<bool>("IsRemoved")
.ValueGeneratedOnAdd()
@@ -947,7 +945,7 @@ namespace Complex.Infrastructure.Migrations
b.HasOne("Complex.Domain.Entities.Unit", "Unit")
.WithMany()
.HasForeignKey("UnitId")
.OnDelete(DeleteBehavior.Cascade)
.OnDelete(DeleteBehavior.NoAction)
.IsRequired();
b.Navigation("CostCycle");
@@ -977,7 +975,7 @@ namespace Complex.Infrastructure.Migrations
b.HasOne("Complex.Domain.Entities.Unit", null)
.WithMany()
.HasForeignKey("UnitsId")
.OnDelete(DeleteBehavior.Cascade)
.OnDelete(DeleteBehavior.NoAction)
.IsRequired();
});

View File

@@ -7,18 +7,17 @@ services:
environment:
- TZ=Asia/Tehran
- ASPNETCORE_ENVIRONMENT=Production
- ConnectionStrings__Default=Server=sqlserver,1433;TrustServerCertificate=True;Database=ComplexDb;User Id=sa;Password=qwER12#$110;
- ConnectionStrings__ComplexConnection=Server=sqlserver,1433;TrustServerCertificate=True;Database=ComplexDb;User Id=sa;Password=qwER12#$110;
labels:
- "traefik.enable=true"
- "traefik.http.routers.complex.rule=Host(`complex.nabaksoft.ir`)"
- "traefik.http.services.complex.loadbalancer.server.port=80"
- "traefik.http.routers.complex.entrypoints=websecure"
# - "traefik.http.routers.webapp.tls.certresolver=letsencrypt"
- "traefik.http.routers.complex.middlewares=complex-cors@docker"
- "traefik.http.middlewares.complex-cors.headers.accessControlAllowMethods=GET,POST,PUT,DELETE,OPTIONS"
- "traefik.http.middlewares.complex-cors.headers.accessControlAllowHeaders=*"
- "traefik.http.middlewares.complex-cors.headers.accessControlAllowOriginList=https://*.nabaksoft.ir,http://192.168.8.108"
- "traefik.http.middlewares.webapp-cors.headers.accessControlAllowCredentials=true"
- "traefik.http.middlewares.complex-cors.headers.accessControlAllowCredentials=true"
- "traefik.http.middlewares.complex-cors.headers.addVaryHeader=true"
networks:
- services
@@ -26,4 +25,4 @@ services:
networks:
services:
external: true
external: true