From 29ee2a76f65226b2af7dc9ac755132002019c135 Mon Sep 17 00:00:00 2001 From: Eric <36512385+PhucNghi176@users.noreply.github.com> Date: Sat, 28 Sep 2024 01:36:51 +0700 Subject: [PATCH] Revert "Revert "Add new entities and update EF Core migration"" --- MBS-COMMAND.API/appsettings.Development.json | 4 +- MBS-COMMAND.API/logs/log-20240927.txt | 21 + .../Abstractions/Entities/Entity.cs | 7 + .../Abstractions/Entities/IEntity.cs | 5 +- MBS_COMMAND.Domain/Entities/Category.cs | 10 + MBS_COMMAND.Domain/Entities/Certificate.cs | 14 + MBS_COMMAND.Domain/Entities/Config.cs | 10 + MBS_COMMAND.Domain/Entities/Feedback.cs | 15 + MBS_COMMAND.Domain/Entities/Group.cs | 16 + .../Entities/Group_Student_Mapping.cs | 11 + MBS_COMMAND.Domain/Entities/Project.cs | 15 + MBS_COMMAND.Domain/Entities/Schedule.cs | 20 + MBS_COMMAND.Domain/Entities/Semester.cs | 12 + MBS_COMMAND.Domain/Entities/Skill.cs | 14 + MBS_COMMAND.Domain/Entities/Slot.cs | 16 + MBS_COMMAND.Domain/Entities/Subject.cs | 20 + MBS_COMMAND.Domain/Entities/Transaction.cs | 17 + MBS_COMMAND.Domain/Entities/User.cs | 20 + MBS_COMMAND.Domain/MBS_COMMAND.Domain.csproj | 4 - .../ApplicationDbContext.cs | 24 +- .../Group_Student_MappingConfiguration.cs | 18 + .../Constants/TableNames.cs | 16 +- .../Migrations/20240927095211_v2.Designer.cs | 648 ++++++++++++++++++ .../Migrations/20240927095211_v2.cs | 453 ++++++++++++ .../ApplicationDbContextModelSnapshot.cs | 587 ++++++++++++++++ 25 files changed, 1979 insertions(+), 18 deletions(-) create mode 100644 MBS-COMMAND.API/logs/log-20240927.txt create mode 100644 MBS_COMMAND.Domain/Entities/Category.cs create mode 100644 MBS_COMMAND.Domain/Entities/Certificate.cs create mode 100644 MBS_COMMAND.Domain/Entities/Config.cs create mode 100644 MBS_COMMAND.Domain/Entities/Feedback.cs create mode 100644 MBS_COMMAND.Domain/Entities/Group.cs create mode 100644 MBS_COMMAND.Domain/Entities/Group_Student_Mapping.cs create mode 100644 MBS_COMMAND.Domain/Entities/Project.cs create mode 100644 MBS_COMMAND.Domain/Entities/Schedule.cs create mode 100644 MBS_COMMAND.Domain/Entities/Semester.cs create mode 100644 MBS_COMMAND.Domain/Entities/Skill.cs create mode 100644 MBS_COMMAND.Domain/Entities/Slot.cs create mode 100644 MBS_COMMAND.Domain/Entities/Subject.cs create mode 100644 MBS_COMMAND.Domain/Entities/Transaction.cs create mode 100644 MBS_COMMAND.Domain/Entities/User.cs create mode 100644 MBS_COMMAND.Persistence/Configurations/Group_Student_MappingConfiguration.cs create mode 100644 MBS_COMMAND.Persistence/Migrations/20240927095211_v2.Designer.cs create mode 100644 MBS_COMMAND.Persistence/Migrations/20240927095211_v2.cs diff --git a/MBS-COMMAND.API/appsettings.Development.json b/MBS-COMMAND.API/appsettings.Development.json index 486c814..09231b0 100644 --- a/MBS-COMMAND.API/appsettings.Development.json +++ b/MBS-COMMAND.API/appsettings.Development.json @@ -1,7 +1,7 @@ { "ConnectionStrings": { - "ConnectionStrings": "Server=14.225.205.54;Database=AntreeDB;Uid=sa;Pwd=Thientan291157@;Trust Server Certificate=True;", - "Redis": "103.162.14.116:6379" + "ConnectionStrings": "Server=103.185.184.35;Database=PRNSUPPER;Uid=sa;Pwd=AnhBiLongDaiKa@;Trust Server Certificate=True;", + "Redis": "103.185.184.35:6379,password=Thientan291157@,abortConnect=false" }, "JwtOption": { "Issuer": "http://103.162.14.116:8080", diff --git a/MBS-COMMAND.API/logs/log-20240927.txt b/MBS-COMMAND.API/logs/log-20240927.txt new file mode 100644 index 0000000..8913b63 --- /dev/null +++ b/MBS-COMMAND.API/logs/log-20240927.txt @@ -0,0 +1,21 @@ +2024-09-27 16:52:10.778 +07:00 [WRN] Sensitive data logging is enabled. Log entries and exception messages may include sensitive application data; this mode should only be enabled during development. +2024-09-27 16:52:29.724 +07:00 [WRN] Sensitive data logging is enabled. Log entries and exception messages may include sensitive application data; this mode should only be enabled during development. +2024-09-27 16:52:30.787 +07:00 [ERR] Failed executing DbCommand (43ms) [Parameters=[], CommandType='"Text"', CommandTimeout='30'] +CREATE TABLE [Users] ( + [Id] uniqueidentifier NOT NULL, + [Email] nvarchar(max) NOT NULL, + [FullName] nvarchar(max) NULL, + [Password] nvarchar(max) NOT NULL, + [Gender] bit NOT NULL, + [Phonenumber] nvarchar(max) NOT NULL, + [Role] int NOT NULL, + [Points] int NOT NULL, + [Status] int NOT NULL, + [MentorId] uniqueidentifier NULL, + [CreatedOnUtc] datetimeoffset NOT NULL, + [ModifiedOnUtc] datetimeoffset NULL, + [IsDeleted] bit NOT NULL, + CONSTRAINT [PK_Users] PRIMARY KEY ([Id]), + CONSTRAINT [FK_Users_Users_MentorId] FOREIGN KEY ([MentorId]) REFERENCES [Users] ([Id]) +); +2024-09-27 16:53:37.481 +07:00 [WRN] Sensitive data logging is enabled. Log entries and exception messages may include sensitive application data; this mode should only be enabled during development. diff --git a/MBS_COMMAND.Domain/Abstractions/Entities/Entity.cs b/MBS_COMMAND.Domain/Abstractions/Entities/Entity.cs index c402ed0..b7323e5 100644 --- a/MBS_COMMAND.Domain/Abstractions/Entities/Entity.cs +++ b/MBS_COMMAND.Domain/Abstractions/Entities/Entity.cs @@ -5,4 +5,11 @@ public abstract class Entity : IEntity public T Id { get; protected set; } public bool IsDeleted { get; protected set; } +} +public abstract class Entity : Entity, IEntity +{ + protected Entity() + { + Id = Guid.NewGuid(); + } } \ No newline at end of file diff --git a/MBS_COMMAND.Domain/Abstractions/Entities/IEntity.cs b/MBS_COMMAND.Domain/Abstractions/Entities/IEntity.cs index 291feec..74c25ba 100644 --- a/MBS_COMMAND.Domain/Abstractions/Entities/IEntity.cs +++ b/MBS_COMMAND.Domain/Abstractions/Entities/IEntity.cs @@ -1,6 +1,3 @@ namespace MBS_COMMAND.Domain.Abstractions.Entities; -public interface IEntity -{ - -} \ No newline at end of file +public interface IEntity; diff --git a/MBS_COMMAND.Domain/Entities/Category.cs b/MBS_COMMAND.Domain/Entities/Category.cs new file mode 100644 index 0000000..194de74 --- /dev/null +++ b/MBS_COMMAND.Domain/Entities/Category.cs @@ -0,0 +1,10 @@ +using MBS_COMMAND.Domain.Abstractions.Entities; + +namespace MBS_COMMAND.Domain.Entities; + +public class Category : Entity, IAuditableEntity +{ + public string Name { get; set; } + public DateTimeOffset CreatedOnUtc { get; set; } + public DateTimeOffset? ModifiedOnUtc { get; set; } +} diff --git a/MBS_COMMAND.Domain/Entities/Certificate.cs b/MBS_COMMAND.Domain/Entities/Certificate.cs new file mode 100644 index 0000000..9e5c5d2 --- /dev/null +++ b/MBS_COMMAND.Domain/Entities/Certificate.cs @@ -0,0 +1,14 @@ +using MBS_COMMAND.Domain.Abstractions.Entities; + +namespace MBS_COMMAND.Domain.Entities; + +public class Certificate : Entity,IAuditableEntity +{ + public string Name { get; set; } + public string Description { get; set; } + public string ImageUrl { get; set; } + public Guid CategoryId { get; set; } + public virtual Category? Category { get; set; } + public DateTimeOffset CreatedOnUtc { get ; set ; } + public DateTimeOffset? ModifiedOnUtc { get ; set ; } +} diff --git a/MBS_COMMAND.Domain/Entities/Config.cs b/MBS_COMMAND.Domain/Entities/Config.cs new file mode 100644 index 0000000..e19d98b --- /dev/null +++ b/MBS_COMMAND.Domain/Entities/Config.cs @@ -0,0 +1,10 @@ +using System.ComponentModel.DataAnnotations; + +namespace MBS_COMMAND.Domain.Entities; + +public class Config +{ + [Key] + public string Key { get; set; } + public int Value { get; set; } +} diff --git a/MBS_COMMAND.Domain/Entities/Feedback.cs b/MBS_COMMAND.Domain/Entities/Feedback.cs new file mode 100644 index 0000000..49dd02c --- /dev/null +++ b/MBS_COMMAND.Domain/Entities/Feedback.cs @@ -0,0 +1,15 @@ +using MBS_COMMAND.Domain.Abstractions.Entities; + +namespace MBS_COMMAND.Domain.Entities; + +public class Feedback : Entity, IAuditableEntity +{ + + public string? Content { get; set; } + public int Rating { get; set; } + public Guid? SlotId { get; set; } + public virtual Slot? Slot { get; set; } + public bool IsMentor { get; set; } + public DateTimeOffset CreatedOnUtc { get; set; } + public DateTimeOffset? ModifiedOnUtc { get; set; } +} diff --git a/MBS_COMMAND.Domain/Entities/Group.cs b/MBS_COMMAND.Domain/Entities/Group.cs new file mode 100644 index 0000000..c511844 --- /dev/null +++ b/MBS_COMMAND.Domain/Entities/Group.cs @@ -0,0 +1,16 @@ +using MBS_AUTHORIZATION.Domain.Entities; +using MBS_COMMAND.Domain.Abstractions.Entities; + +namespace MBS_COMMAND.Domain.Entities; + +public class Group : Entity, IAuditableEntity +{ + public string Name { get; set; } + public Guid? MentorId { get; set; } + public virtual User? Mentor { get; set; } + public string Stack { get; set; } + public Guid? ProjectId { get; set; } + public virtual Project? Project { get; set; } + public DateTimeOffset CreatedOnUtc { get ; set ; } + public DateTimeOffset? ModifiedOnUtc { get ; set ; } +} diff --git a/MBS_COMMAND.Domain/Entities/Group_Student_Mapping.cs b/MBS_COMMAND.Domain/Entities/Group_Student_Mapping.cs new file mode 100644 index 0000000..7c91690 --- /dev/null +++ b/MBS_COMMAND.Domain/Entities/Group_Student_Mapping.cs @@ -0,0 +1,11 @@ +using MBS_AUTHORIZATION.Domain.Entities; + +namespace MBS_COMMAND.Domain.Entities; + +public class Group_Student_Mapping +{ + public Guid GroupId { get; set; } + public virtual Group Group { get; set; } + public Guid StudentId { get; set; } + public virtual User Student { get; set; } +} diff --git a/MBS_COMMAND.Domain/Entities/Project.cs b/MBS_COMMAND.Domain/Entities/Project.cs new file mode 100644 index 0000000..1739adb --- /dev/null +++ b/MBS_COMMAND.Domain/Entities/Project.cs @@ -0,0 +1,15 @@ +using MBS_COMMAND.Domain.Abstractions.Entities; + +namespace MBS_COMMAND.Domain.Entities; + +public class Project : Entity, IAuditableEntity +{ + public string Name { get ; set ; } + public string Description { get ; set ; } + + + + + public DateTimeOffset CreatedOnUtc { get ; set ; } + public DateTimeOffset? ModifiedOnUtc { get ; set ; } +} diff --git a/MBS_COMMAND.Domain/Entities/Schedule.cs b/MBS_COMMAND.Domain/Entities/Schedule.cs new file mode 100644 index 0000000..772e150 --- /dev/null +++ b/MBS_COMMAND.Domain/Entities/Schedule.cs @@ -0,0 +1,20 @@ +using MBS_AUTHORIZATION.Domain.Entities; +using MBS_COMMAND.Domain.Abstractions.Entities; + +namespace MBS_COMMAND.Domain.Entities; + +public class Schedule : Entity, IAuditableEntity +{ + public Guid MentorId { get; set; } + public virtual User? Mentor { get; set; } + + public Guid GroupId { get; set; } + public virtual Group? Group { get; set; } + public TimeOnly StartTime { get; set; } + public TimeOnly EndTime { get; set; } + public DateOnly Date { get; set; } + public Guid SubjectId { get; set; } + public virtual Subject? Subject { get; set; } + public DateTimeOffset CreatedOnUtc { get ; set ; } + public DateTimeOffset? ModifiedOnUtc { get ; set ; } +} diff --git a/MBS_COMMAND.Domain/Entities/Semester.cs b/MBS_COMMAND.Domain/Entities/Semester.cs new file mode 100644 index 0000000..e194af5 --- /dev/null +++ b/MBS_COMMAND.Domain/Entities/Semester.cs @@ -0,0 +1,12 @@ +using MBS_COMMAND.Domain.Abstractions.Entities; + +namespace MBS_COMMAND.Domain.Entities; + +public class Semester : Entity, IAuditableEntity +{ + public string Name { get; set; } + public DateOnly From { get; set; } + public DateOnly To { get; set; } + public DateTimeOffset CreatedOnUtc { get; set; } + public DateTimeOffset? ModifiedOnUtc { get; set; } +} diff --git a/MBS_COMMAND.Domain/Entities/Skill.cs b/MBS_COMMAND.Domain/Entities/Skill.cs new file mode 100644 index 0000000..ba506c2 --- /dev/null +++ b/MBS_COMMAND.Domain/Entities/Skill.cs @@ -0,0 +1,14 @@ +using MBS_COMMAND.Domain.Abstractions.Entities; + +namespace MBS_COMMAND.Domain.Entities; + +public class Skill : Entity, IAuditableEntity +{ + + public Guid? CategoryId { get; set; } + public virtual Category? Category { get; set; } + public string Name { get; set; } + public string Description { get; set; } + public DateTimeOffset CreatedOnUtc { get; set; } + public DateTimeOffset? ModifiedOnUtc { get; set; } +} diff --git a/MBS_COMMAND.Domain/Entities/Slot.cs b/MBS_COMMAND.Domain/Entities/Slot.cs new file mode 100644 index 0000000..a6d443e --- /dev/null +++ b/MBS_COMMAND.Domain/Entities/Slot.cs @@ -0,0 +1,16 @@ +using MBS_AUTHORIZATION.Domain.Entities; +using MBS_COMMAND.Domain.Abstractions.Entities; + +namespace MBS_COMMAND.Domain.Entities; + +public class Slot : Entity, IAuditableEntity +{ + public Guid? MentorId { get; set; } + public virtual User? Mentor { get; set; } + public TimeOnly StartTime { get; set; } + public TimeOnly EndTime { get; set; } + public DateOnly Date { get; set; } + public int Status { get; set; } + public DateTimeOffset CreatedOnUtc { get; set; } + public DateTimeOffset? ModifiedOnUtc { get; set; } +} diff --git a/MBS_COMMAND.Domain/Entities/Subject.cs b/MBS_COMMAND.Domain/Entities/Subject.cs new file mode 100644 index 0000000..0172ed3 --- /dev/null +++ b/MBS_COMMAND.Domain/Entities/Subject.cs @@ -0,0 +1,20 @@ +using MBS_COMMAND.Domain.Abstractions.Entities; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace MBS_COMMAND.Domain.Entities; + +public class Subject : Entity, IAuditableEntity +{ + public string Name { get ; set ; } + public int Status { get ; set ; } + public Guid SemesterId { get; set; } + public virtual Semester? Semester { get; set; } + + + public DateTimeOffset CreatedOnUtc { get ; set ; } + public DateTimeOffset? ModifiedOnUtc { get ; set ; } +} diff --git a/MBS_COMMAND.Domain/Entities/Transaction.cs b/MBS_COMMAND.Domain/Entities/Transaction.cs new file mode 100644 index 0000000..684c41b --- /dev/null +++ b/MBS_COMMAND.Domain/Entities/Transaction.cs @@ -0,0 +1,17 @@ +using MBS_AUTHORIZATION.Domain.Entities; +using MBS_COMMAND.Domain.Abstractions.Entities; + +namespace MBS_COMMAND.Domain.Entities; + +public class Transaction : Entity, IAuditableEntity +{ + public Guid? UserId { get; set; } + public virtual User? User { get; set; } + public Guid? SlotId { get; set; } + public virtual Slot? Slot { get; set; } + public DateOnly Date { get; set; } + public int Status { get; set; } + + public DateTimeOffset CreatedOnUtc { get; set; } + public DateTimeOffset? ModifiedOnUtc { get; set; } +} diff --git a/MBS_COMMAND.Domain/Entities/User.cs b/MBS_COMMAND.Domain/Entities/User.cs new file mode 100644 index 0000000..b4b2b35 --- /dev/null +++ b/MBS_COMMAND.Domain/Entities/User.cs @@ -0,0 +1,20 @@ +using MBS_COMMAND.Domain.Abstractions.Entities; + +namespace MBS_AUTHORIZATION.Domain.Entities; + +public class User : Entity, IAuditableEntity +{ + public string Email { get; set; } + public string? FullName { get; set; } + public string Password { get; set; } + public bool Gender { get; set; } + public string Phonenumber { get; set; } + public int Role { get; set; } + public int Points { get; set; } + public int Status { get; set; } + public Guid? MentorId { get; set; } + + public virtual User? Mentor { get; set; } + public DateTimeOffset CreatedOnUtc { get; set; } + public DateTimeOffset? ModifiedOnUtc { get; set; } +} \ No newline at end of file diff --git a/MBS_COMMAND.Domain/MBS_COMMAND.Domain.csproj b/MBS_COMMAND.Domain/MBS_COMMAND.Domain.csproj index cdd5cd5..1f5e2ed 100644 --- a/MBS_COMMAND.Domain/MBS_COMMAND.Domain.csproj +++ b/MBS_COMMAND.Domain/MBS_COMMAND.Domain.csproj @@ -10,8 +10,4 @@ - - - - diff --git a/MBS_COMMAND.Persistence/ApplicationDbContext.cs b/MBS_COMMAND.Persistence/ApplicationDbContext.cs index ee26f25..33f9ad6 100644 --- a/MBS_COMMAND.Persistence/ApplicationDbContext.cs +++ b/MBS_COMMAND.Persistence/ApplicationDbContext.cs @@ -1,3 +1,5 @@ +using MBS_AUTHORIZATION.Domain.Entities; +using MBS_COMMAND.Domain.Entities; using Microsoft.EntityFrameworkCore; namespace MBS_COMMAND.Persistence; @@ -12,11 +14,19 @@ public ApplicationDbContext(DbContextOptions options) protected override void OnModelCreating(ModelBuilder builder) => builder.ApplyConfigurationsFromAssembly(AssemblyReference.Assembly); - // public DbSet AppUses { get; set; } - // public DbSet Actions { get; set; } - // public DbSet Functions { get; set; } - // public DbSet ActionInFunctions { get; set; } - // public DbSet Permissions { get; set; } - // - // public DbSet Products { get; set; } + public virtual DbSet Categories { get; set; } + public virtual DbSet Certificates { get; set; } + public virtual DbSet Configs { get; set; } + public virtual DbSet Feedbacks { get; set; } + public virtual DbSet Groups { get; set; } + public virtual DbSet group_Student_Mappings { get; set; } + public virtual DbSet Projects { get; set; } + public virtual DbSet Schedules { get; set; } + public virtual DbSet Semesters { get; set; } + public virtual DbSet Skills { get; set; } + public virtual DbSet Slots { get; set; } + public virtual DbSet Subjects { get; set; } + public virtual DbSet Transactions { get; set; } + public virtual DbSet Users { get; set; } + } \ No newline at end of file diff --git a/MBS_COMMAND.Persistence/Configurations/Group_Student_MappingConfiguration.cs b/MBS_COMMAND.Persistence/Configurations/Group_Student_MappingConfiguration.cs new file mode 100644 index 0000000..979223a --- /dev/null +++ b/MBS_COMMAND.Persistence/Configurations/Group_Student_MappingConfiguration.cs @@ -0,0 +1,18 @@ +using MBS_COMMAND.Domain.Entities; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Metadata.Builders; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace MBS_COMMAND.Persistence.Configurations; + +public class Group_Student_MappingConfiguration : IEntityTypeConfiguration +{ + public void Configure(EntityTypeBuilder builder) + { + builder.HasKey(x => new { x.GroupId, x.StudentId }); + } +} diff --git a/MBS_COMMAND.Persistence/Constants/TableNames.cs b/MBS_COMMAND.Persistence/Constants/TableNames.cs index 0836402..36dd373 100644 --- a/MBS_COMMAND.Persistence/Constants/TableNames.cs +++ b/MBS_COMMAND.Persistence/Constants/TableNames.cs @@ -6,5 +6,19 @@ internal static class TableNames internal const string OutboxMessages = nameof(OutboxMessages); // *********** Singular Nouns *********** - internal const string Product = nameof(Product); + internal const string Category = nameof(Category); + internal const string Certificate = nameof(Certificate); + internal const string Config = nameof(Config); + internal const string Feedback = nameof(Feedback); + internal const string Group = nameof(Group); + internal const string Group_Student_Mapping = nameof(Group_Student_Mapping); + internal const string Project = nameof(Project); + internal const string Schedule = nameof(Schedule); + internal const string Semester = nameof(Semester); + internal const string Skill = nameof(Skill); + internal const string Slot = nameof(Slot); + internal const string Subject = nameof(Subject); + internal const string Transaction = nameof(Transaction); + internal const string User = nameof(User); + } \ No newline at end of file diff --git a/MBS_COMMAND.Persistence/Migrations/20240927095211_v2.Designer.cs b/MBS_COMMAND.Persistence/Migrations/20240927095211_v2.Designer.cs new file mode 100644 index 0000000..3e7c265 --- /dev/null +++ b/MBS_COMMAND.Persistence/Migrations/20240927095211_v2.Designer.cs @@ -0,0 +1,648 @@ +// +using System; +using MBS_COMMAND.Persistence; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +#nullable disable + +namespace MBS_COMMAND.Persistence.Migrations +{ + [DbContext(typeof(ApplicationDbContext))] + [Migration("20240927095211_v2")] + partial class v2 + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "8.0.7") + .HasAnnotation("Proxies:ChangeTracking", false) + .HasAnnotation("Proxies:CheckEquality", false) + .HasAnnotation("Proxies:LazyLoading", true) + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); + + modelBuilder.Entity("MBS_AUTHORIZATION.Domain.Entities.User", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("CreatedOnUtc") + .HasColumnType("datetimeoffset"); + + b.Property("Email") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("FullName") + .HasColumnType("nvarchar(max)"); + + b.Property("Gender") + .HasColumnType("bit"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("MentorId") + .HasColumnType("uniqueidentifier"); + + b.Property("ModifiedOnUtc") + .HasColumnType("datetimeoffset"); + + b.Property("Password") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Phonenumber") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Points") + .HasColumnType("int"); + + b.Property("Role") + .HasColumnType("int"); + + b.Property("Status") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("MentorId"); + + b.ToTable("Users"); + }); + + modelBuilder.Entity("MBS_COMMAND.Domain.Entities.Category", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("CreatedOnUtc") + .HasColumnType("datetimeoffset"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("ModifiedOnUtc") + .HasColumnType("datetimeoffset"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("Categories"); + }); + + modelBuilder.Entity("MBS_COMMAND.Domain.Entities.Certificate", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("CategoryId") + .HasColumnType("uniqueidentifier"); + + b.Property("CreatedOnUtc") + .HasColumnType("datetimeoffset"); + + b.Property("Description") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ImageUrl") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("ModifiedOnUtc") + .HasColumnType("datetimeoffset"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.HasIndex("CategoryId"); + + b.ToTable("Certificates"); + }); + + modelBuilder.Entity("MBS_COMMAND.Domain.Entities.Config", b => + { + b.Property("Key") + .HasColumnType("nvarchar(450)"); + + b.Property("Value") + .HasColumnType("int"); + + b.HasKey("Key"); + + b.ToTable("Configs"); + }); + + modelBuilder.Entity("MBS_COMMAND.Domain.Entities.Feedback", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("Content") + .HasColumnType("nvarchar(max)"); + + b.Property("CreatedOnUtc") + .HasColumnType("datetimeoffset"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("IsMentor") + .HasColumnType("bit"); + + b.Property("ModifiedOnUtc") + .HasColumnType("datetimeoffset"); + + b.Property("Rating") + .HasColumnType("int"); + + b.Property("SlotId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("SlotId"); + + b.ToTable("Feedbacks"); + }); + + modelBuilder.Entity("MBS_COMMAND.Domain.Entities.Group", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("CreatedOnUtc") + .HasColumnType("datetimeoffset"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("MentorId") + .HasColumnType("uniqueidentifier"); + + b.Property("ModifiedOnUtc") + .HasColumnType("datetimeoffset"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ProjectId") + .HasColumnType("uniqueidentifier"); + + b.Property("Stack") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.HasIndex("MentorId"); + + b.HasIndex("ProjectId"); + + b.ToTable("Groups"); + }); + + modelBuilder.Entity("MBS_COMMAND.Domain.Entities.Group_Student_Mapping", b => + { + b.Property("GroupId") + .HasColumnType("uniqueidentifier"); + + b.Property("StudentId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("GroupId", "StudentId"); + + b.HasIndex("StudentId"); + + b.ToTable("group_Student_Mappings"); + }); + + modelBuilder.Entity("MBS_COMMAND.Domain.Entities.Project", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("CreatedOnUtc") + .HasColumnType("datetimeoffset"); + + b.Property("Description") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("ModifiedOnUtc") + .HasColumnType("datetimeoffset"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("Projects"); + }); + + modelBuilder.Entity("MBS_COMMAND.Domain.Entities.Schedule", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("CreatedOnUtc") + .HasColumnType("datetimeoffset"); + + b.Property("Date") + .HasColumnType("date"); + + b.Property("EndTime") + .HasColumnType("time"); + + b.Property("GroupId") + .HasColumnType("uniqueidentifier"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("MentorId") + .HasColumnType("uniqueidentifier"); + + b.Property("ModifiedOnUtc") + .HasColumnType("datetimeoffset"); + + b.Property("StartTime") + .HasColumnType("time"); + + b.Property("SubjectId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("GroupId"); + + b.HasIndex("MentorId"); + + b.HasIndex("SubjectId"); + + b.ToTable("Schedules"); + }); + + modelBuilder.Entity("MBS_COMMAND.Domain.Entities.Semester", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("CreatedOnUtc") + .HasColumnType("datetimeoffset"); + + b.Property("From") + .HasColumnType("date"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("ModifiedOnUtc") + .HasColumnType("datetimeoffset"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("To") + .HasColumnType("date"); + + b.HasKey("Id"); + + b.ToTable("Semesters"); + }); + + modelBuilder.Entity("MBS_COMMAND.Domain.Entities.Skill", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("CategoryId") + .HasColumnType("uniqueidentifier"); + + b.Property("CreatedOnUtc") + .HasColumnType("datetimeoffset"); + + b.Property("Description") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("ModifiedOnUtc") + .HasColumnType("datetimeoffset"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.HasIndex("CategoryId"); + + b.ToTable("Skills"); + }); + + modelBuilder.Entity("MBS_COMMAND.Domain.Entities.Slot", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("CreatedOnUtc") + .HasColumnType("datetimeoffset"); + + b.Property("Date") + .HasColumnType("date"); + + b.Property("EndTime") + .HasColumnType("time"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("MentorId") + .HasColumnType("uniqueidentifier"); + + b.Property("ModifiedOnUtc") + .HasColumnType("datetimeoffset"); + + b.Property("StartTime") + .HasColumnType("time"); + + b.Property("Status") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("MentorId"); + + b.ToTable("Slots"); + }); + + modelBuilder.Entity("MBS_COMMAND.Domain.Entities.Subject", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("CreatedOnUtc") + .HasColumnType("datetimeoffset"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("ModifiedOnUtc") + .HasColumnType("datetimeoffset"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("SemesterId") + .HasColumnType("uniqueidentifier"); + + b.Property("Status") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("SemesterId"); + + b.ToTable("Subjects"); + }); + + modelBuilder.Entity("MBS_COMMAND.Domain.Entities.Transaction", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("CreatedOnUtc") + .HasColumnType("datetimeoffset"); + + b.Property("Date") + .HasColumnType("date"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("ModifiedOnUtc") + .HasColumnType("datetimeoffset"); + + b.Property("SlotId") + .HasColumnType("uniqueidentifier"); + + b.Property("Status") + .HasColumnType("int"); + + b.Property("UserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("SlotId"); + + b.HasIndex("UserId"); + + b.ToTable("Transactions"); + }); + + modelBuilder.Entity("MBS_COMMAND.Persistence.Outbox.OutboxMessage", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("Content") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Error") + .HasColumnType("nvarchar(max)"); + + b.Property("OccurredOnUtc") + .HasColumnType("datetimeoffset"); + + b.Property("ProcessedOnUtc") + .HasColumnType("datetimeoffset"); + + b.Property("Type") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("OutboxMessages", (string)null); + }); + + modelBuilder.Entity("MBS_AUTHORIZATION.Domain.Entities.User", b => + { + b.HasOne("MBS_AUTHORIZATION.Domain.Entities.User", "Mentor") + .WithMany() + .HasForeignKey("MentorId"); + + b.Navigation("Mentor"); + }); + + modelBuilder.Entity("MBS_COMMAND.Domain.Entities.Certificate", b => + { + b.HasOne("MBS_COMMAND.Domain.Entities.Category", "Category") + .WithMany() + .HasForeignKey("CategoryId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Category"); + }); + + modelBuilder.Entity("MBS_COMMAND.Domain.Entities.Feedback", b => + { + b.HasOne("MBS_COMMAND.Domain.Entities.Slot", "Slot") + .WithMany() + .HasForeignKey("SlotId"); + + b.Navigation("Slot"); + }); + + modelBuilder.Entity("MBS_COMMAND.Domain.Entities.Group", b => + { + b.HasOne("MBS_AUTHORIZATION.Domain.Entities.User", "Mentor") + .WithMany() + .HasForeignKey("MentorId"); + + b.HasOne("MBS_COMMAND.Domain.Entities.Project", "Project") + .WithMany() + .HasForeignKey("ProjectId"); + + b.Navigation("Mentor"); + + b.Navigation("Project"); + }); + + modelBuilder.Entity("MBS_COMMAND.Domain.Entities.Group_Student_Mapping", b => + { + b.HasOne("MBS_COMMAND.Domain.Entities.Group", "Group") + .WithMany() + .HasForeignKey("GroupId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("MBS_AUTHORIZATION.Domain.Entities.User", "Student") + .WithMany() + .HasForeignKey("StudentId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Group"); + + b.Navigation("Student"); + }); + + modelBuilder.Entity("MBS_COMMAND.Domain.Entities.Schedule", b => + { + b.HasOne("MBS_COMMAND.Domain.Entities.Group", "Group") + .WithMany() + .HasForeignKey("GroupId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("MBS_AUTHORIZATION.Domain.Entities.User", "Mentor") + .WithMany() + .HasForeignKey("MentorId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("MBS_COMMAND.Domain.Entities.Subject", "Subject") + .WithMany() + .HasForeignKey("SubjectId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Group"); + + b.Navigation("Mentor"); + + b.Navigation("Subject"); + }); + + modelBuilder.Entity("MBS_COMMAND.Domain.Entities.Skill", b => + { + b.HasOne("MBS_COMMAND.Domain.Entities.Category", "Category") + .WithMany() + .HasForeignKey("CategoryId"); + + b.Navigation("Category"); + }); + + modelBuilder.Entity("MBS_COMMAND.Domain.Entities.Slot", b => + { + b.HasOne("MBS_AUTHORIZATION.Domain.Entities.User", "Mentor") + .WithMany() + .HasForeignKey("MentorId"); + + b.Navigation("Mentor"); + }); + + modelBuilder.Entity("MBS_COMMAND.Domain.Entities.Subject", b => + { + b.HasOne("MBS_COMMAND.Domain.Entities.Semester", "Semester") + .WithMany() + .HasForeignKey("SemesterId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Semester"); + }); + + modelBuilder.Entity("MBS_COMMAND.Domain.Entities.Transaction", b => + { + b.HasOne("MBS_COMMAND.Domain.Entities.Slot", "Slot") + .WithMany() + .HasForeignKey("SlotId"); + + b.HasOne("MBS_AUTHORIZATION.Domain.Entities.User", "User") + .WithMany() + .HasForeignKey("UserId"); + + b.Navigation("Slot"); + + b.Navigation("User"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/MBS_COMMAND.Persistence/Migrations/20240927095211_v2.cs b/MBS_COMMAND.Persistence/Migrations/20240927095211_v2.cs new file mode 100644 index 0000000..70d7e9e --- /dev/null +++ b/MBS_COMMAND.Persistence/Migrations/20240927095211_v2.cs @@ -0,0 +1,453 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace MBS_COMMAND.Persistence.Migrations +{ + /// + public partial class v2 : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.CreateTable( + name: "Categories", + columns: table => new + { + Id = table.Column(type: "uniqueidentifier", nullable: false), + Name = table.Column(type: "nvarchar(max)", nullable: false), + CreatedOnUtc = table.Column(type: "datetimeoffset", nullable: false), + ModifiedOnUtc = table.Column(type: "datetimeoffset", nullable: true), + IsDeleted = table.Column(type: "bit", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Categories", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "Configs", + columns: table => new + { + Key = table.Column(type: "nvarchar(450)", nullable: false), + Value = table.Column(type: "int", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Configs", x => x.Key); + }); + + migrationBuilder.CreateTable( + name: "Projects", + columns: table => new + { + Id = table.Column(type: "uniqueidentifier", nullable: false), + Name = table.Column(type: "nvarchar(max)", nullable: false), + Description = table.Column(type: "nvarchar(max)", nullable: false), + CreatedOnUtc = table.Column(type: "datetimeoffset", nullable: false), + ModifiedOnUtc = table.Column(type: "datetimeoffset", nullable: true), + IsDeleted = table.Column(type: "bit", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Projects", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "Semesters", + columns: table => new + { + Id = table.Column(type: "uniqueidentifier", nullable: false), + Name = table.Column(type: "nvarchar(max)", nullable: false), + From = table.Column(type: "date", nullable: false), + To = table.Column(type: "date", nullable: false), + CreatedOnUtc = table.Column(type: "datetimeoffset", nullable: false), + ModifiedOnUtc = table.Column(type: "datetimeoffset", nullable: true), + IsDeleted = table.Column(type: "bit", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Semesters", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "Users", + columns: table => new + { + Id = table.Column(type: "uniqueidentifier", nullable: false), + Email = table.Column(type: "nvarchar(max)", nullable: false), + FullName = table.Column(type: "nvarchar(max)", nullable: true), + Password = table.Column(type: "nvarchar(max)", nullable: false), + Gender = table.Column(type: "bit", nullable: false), + Phonenumber = table.Column(type: "nvarchar(max)", nullable: false), + Role = table.Column(type: "int", nullable: false), + Points = table.Column(type: "int", nullable: false), + Status = table.Column(type: "int", nullable: false), + MentorId = table.Column(type: "uniqueidentifier", nullable: true), + CreatedOnUtc = table.Column(type: "datetimeoffset", nullable: false), + ModifiedOnUtc = table.Column(type: "datetimeoffset", nullable: true), + IsDeleted = table.Column(type: "bit", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Users", x => x.Id); + table.ForeignKey( + name: "FK_Users_Users_MentorId", + column: x => x.MentorId, + principalTable: "Users", + principalColumn: "Id"); + }); + + migrationBuilder.CreateTable( + name: "Certificates", + columns: table => new + { + Id = table.Column(type: "uniqueidentifier", nullable: false), + Name = table.Column(type: "nvarchar(max)", nullable: false), + Description = table.Column(type: "nvarchar(max)", nullable: false), + ImageUrl = table.Column(type: "nvarchar(max)", nullable: false), + CategoryId = table.Column(type: "uniqueidentifier", nullable: false), + CreatedOnUtc = table.Column(type: "datetimeoffset", nullable: false), + ModifiedOnUtc = table.Column(type: "datetimeoffset", nullable: true), + IsDeleted = table.Column(type: "bit", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Certificates", x => x.Id); + table.ForeignKey( + name: "FK_Certificates_Categories_CategoryId", + column: x => x.CategoryId, + principalTable: "Categories", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "Skills", + columns: table => new + { + Id = table.Column(type: "uniqueidentifier", nullable: false), + CategoryId = table.Column(type: "uniqueidentifier", nullable: true), + Name = table.Column(type: "nvarchar(max)", nullable: false), + Description = table.Column(type: "nvarchar(max)", nullable: false), + CreatedOnUtc = table.Column(type: "datetimeoffset", nullable: false), + ModifiedOnUtc = table.Column(type: "datetimeoffset", nullable: true), + IsDeleted = table.Column(type: "bit", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Skills", x => x.Id); + table.ForeignKey( + name: "FK_Skills_Categories_CategoryId", + column: x => x.CategoryId, + principalTable: "Categories", + principalColumn: "Id"); + }); + + migrationBuilder.CreateTable( + name: "Subjects", + columns: table => new + { + Id = table.Column(type: "uniqueidentifier", nullable: false), + Name = table.Column(type: "nvarchar(max)", nullable: false), + Status = table.Column(type: "int", nullable: false), + SemesterId = table.Column(type: "uniqueidentifier", nullable: false), + CreatedOnUtc = table.Column(type: "datetimeoffset", nullable: false), + ModifiedOnUtc = table.Column(type: "datetimeoffset", nullable: true), + IsDeleted = table.Column(type: "bit", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Subjects", x => x.Id); + table.ForeignKey( + name: "FK_Subjects_Semesters_SemesterId", + column: x => x.SemesterId, + principalTable: "Semesters", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "Groups", + columns: table => new + { + Id = table.Column(type: "uniqueidentifier", nullable: false), + Name = table.Column(type: "nvarchar(max)", nullable: false), + MentorId = table.Column(type: "uniqueidentifier", nullable: true), + Stack = table.Column(type: "nvarchar(max)", nullable: false), + ProjectId = table.Column(type: "uniqueidentifier", nullable: true), + CreatedOnUtc = table.Column(type: "datetimeoffset", nullable: false), + ModifiedOnUtc = table.Column(type: "datetimeoffset", nullable: true), + IsDeleted = table.Column(type: "bit", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Groups", x => x.Id); + table.ForeignKey( + name: "FK_Groups_Projects_ProjectId", + column: x => x.ProjectId, + principalTable: "Projects", + principalColumn: "Id"); + table.ForeignKey( + name: "FK_Groups_Users_MentorId", + column: x => x.MentorId, + principalTable: "Users", + principalColumn: "Id"); + }); + + migrationBuilder.CreateTable( + name: "Slots", + columns: table => new + { + Id = table.Column(type: "uniqueidentifier", nullable: false), + MentorId = table.Column(type: "uniqueidentifier", nullable: true), + StartTime = table.Column(type: "time", nullable: false), + EndTime = table.Column(type: "time", nullable: false), + Date = table.Column(type: "date", nullable: false), + Status = table.Column(type: "int", nullable: false), + CreatedOnUtc = table.Column(type: "datetimeoffset", nullable: false), + ModifiedOnUtc = table.Column(type: "datetimeoffset", nullable: true), + IsDeleted = table.Column(type: "bit", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Slots", x => x.Id); + table.ForeignKey( + name: "FK_Slots_Users_MentorId", + column: x => x.MentorId, + principalTable: "Users", + principalColumn: "Id"); + }); + + migrationBuilder.CreateTable( + name: "group_Student_Mappings", + columns: table => new + { + GroupId = table.Column(type: "uniqueidentifier", nullable: false), + StudentId = table.Column(type: "uniqueidentifier", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_group_Student_Mappings", x => new { x.GroupId, x.StudentId }); + table.ForeignKey( + name: "FK_group_Student_Mappings_Groups_GroupId", + column: x => x.GroupId, + principalTable: "Groups", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_group_Student_Mappings_Users_StudentId", + column: x => x.StudentId, + principalTable: "Users", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "Schedules", + columns: table => new + { + Id = table.Column(type: "uniqueidentifier", nullable: false), + MentorId = table.Column(type: "uniqueidentifier", nullable: false), + GroupId = table.Column(type: "uniqueidentifier", nullable: false), + StartTime = table.Column(type: "time", nullable: false), + EndTime = table.Column(type: "time", nullable: false), + Date = table.Column(type: "date", nullable: false), + SubjectId = table.Column(type: "uniqueidentifier", nullable: false), + CreatedOnUtc = table.Column(type: "datetimeoffset", nullable: false), + ModifiedOnUtc = table.Column(type: "datetimeoffset", nullable: true), + IsDeleted = table.Column(type: "bit", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Schedules", x => x.Id); + table.ForeignKey( + name: "FK_Schedules_Groups_GroupId", + column: x => x.GroupId, + principalTable: "Groups", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_Schedules_Subjects_SubjectId", + column: x => x.SubjectId, + principalTable: "Subjects", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_Schedules_Users_MentorId", + column: x => x.MentorId, + principalTable: "Users", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "Feedbacks", + columns: table => new + { + Id = table.Column(type: "uniqueidentifier", nullable: false), + Content = table.Column(type: "nvarchar(max)", nullable: true), + Rating = table.Column(type: "int", nullable: false), + SlotId = table.Column(type: "uniqueidentifier", nullable: true), + IsMentor = table.Column(type: "bit", nullable: false), + CreatedOnUtc = table.Column(type: "datetimeoffset", nullable: false), + ModifiedOnUtc = table.Column(type: "datetimeoffset", nullable: true), + IsDeleted = table.Column(type: "bit", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Feedbacks", x => x.Id); + table.ForeignKey( + name: "FK_Feedbacks_Slots_SlotId", + column: x => x.SlotId, + principalTable: "Slots", + principalColumn: "Id"); + }); + + migrationBuilder.CreateTable( + name: "Transactions", + columns: table => new + { + Id = table.Column(type: "uniqueidentifier", nullable: false), + UserId = table.Column(type: "uniqueidentifier", nullable: true), + SlotId = table.Column(type: "uniqueidentifier", nullable: true), + Date = table.Column(type: "date", nullable: false), + Status = table.Column(type: "int", nullable: false), + CreatedOnUtc = table.Column(type: "datetimeoffset", nullable: false), + ModifiedOnUtc = table.Column(type: "datetimeoffset", nullable: true), + IsDeleted = table.Column(type: "bit", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Transactions", x => x.Id); + table.ForeignKey( + name: "FK_Transactions_Slots_SlotId", + column: x => x.SlotId, + principalTable: "Slots", + principalColumn: "Id"); + table.ForeignKey( + name: "FK_Transactions_Users_UserId", + column: x => x.UserId, + principalTable: "Users", + principalColumn: "Id"); + }); + + migrationBuilder.CreateIndex( + name: "IX_Certificates_CategoryId", + table: "Certificates", + column: "CategoryId"); + + migrationBuilder.CreateIndex( + name: "IX_Feedbacks_SlotId", + table: "Feedbacks", + column: "SlotId"); + + migrationBuilder.CreateIndex( + name: "IX_group_Student_Mappings_StudentId", + table: "group_Student_Mappings", + column: "StudentId"); + + migrationBuilder.CreateIndex( + name: "IX_Groups_MentorId", + table: "Groups", + column: "MentorId"); + + migrationBuilder.CreateIndex( + name: "IX_Groups_ProjectId", + table: "Groups", + column: "ProjectId"); + + migrationBuilder.CreateIndex( + name: "IX_Schedules_GroupId", + table: "Schedules", + column: "GroupId"); + + migrationBuilder.CreateIndex( + name: "IX_Schedules_MentorId", + table: "Schedules", + column: "MentorId"); + + migrationBuilder.CreateIndex( + name: "IX_Schedules_SubjectId", + table: "Schedules", + column: "SubjectId"); + + migrationBuilder.CreateIndex( + name: "IX_Skills_CategoryId", + table: "Skills", + column: "CategoryId"); + + migrationBuilder.CreateIndex( + name: "IX_Slots_MentorId", + table: "Slots", + column: "MentorId"); + + migrationBuilder.CreateIndex( + name: "IX_Subjects_SemesterId", + table: "Subjects", + column: "SemesterId"); + + migrationBuilder.CreateIndex( + name: "IX_Transactions_SlotId", + table: "Transactions", + column: "SlotId"); + + migrationBuilder.CreateIndex( + name: "IX_Transactions_UserId", + table: "Transactions", + column: "UserId"); + + migrationBuilder.CreateIndex( + name: "IX_Users_MentorId", + table: "Users", + column: "MentorId"); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "Certificates"); + + migrationBuilder.DropTable( + name: "Configs"); + + migrationBuilder.DropTable( + name: "Feedbacks"); + + migrationBuilder.DropTable( + name: "group_Student_Mappings"); + + migrationBuilder.DropTable( + name: "Schedules"); + + migrationBuilder.DropTable( + name: "Skills"); + + migrationBuilder.DropTable( + name: "Transactions"); + + migrationBuilder.DropTable( + name: "Groups"); + + migrationBuilder.DropTable( + name: "Subjects"); + + migrationBuilder.DropTable( + name: "Categories"); + + migrationBuilder.DropTable( + name: "Slots"); + + migrationBuilder.DropTable( + name: "Projects"); + + migrationBuilder.DropTable( + name: "Semesters"); + + migrationBuilder.DropTable( + name: "Users"); + } + } +} diff --git a/MBS_COMMAND.Persistence/Migrations/ApplicationDbContextModelSnapshot.cs b/MBS_COMMAND.Persistence/Migrations/ApplicationDbContextModelSnapshot.cs index 9414aff..c6b8e69 100644 --- a/MBS_COMMAND.Persistence/Migrations/ApplicationDbContextModelSnapshot.cs +++ b/MBS_COMMAND.Persistence/Migrations/ApplicationDbContextModelSnapshot.cs @@ -25,6 +25,459 @@ protected override void BuildModel(ModelBuilder modelBuilder) SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); + modelBuilder.Entity("MBS_AUTHORIZATION.Domain.Entities.User", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("CreatedOnUtc") + .HasColumnType("datetimeoffset"); + + b.Property("Email") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("FullName") + .HasColumnType("nvarchar(max)"); + + b.Property("Gender") + .HasColumnType("bit"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("MentorId") + .HasColumnType("uniqueidentifier"); + + b.Property("ModifiedOnUtc") + .HasColumnType("datetimeoffset"); + + b.Property("Password") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Phonenumber") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Points") + .HasColumnType("int"); + + b.Property("Role") + .HasColumnType("int"); + + b.Property("Status") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("MentorId"); + + b.ToTable("Users"); + }); + + modelBuilder.Entity("MBS_COMMAND.Domain.Entities.Category", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("CreatedOnUtc") + .HasColumnType("datetimeoffset"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("ModifiedOnUtc") + .HasColumnType("datetimeoffset"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("Categories"); + }); + + modelBuilder.Entity("MBS_COMMAND.Domain.Entities.Certificate", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("CategoryId") + .HasColumnType("uniqueidentifier"); + + b.Property("CreatedOnUtc") + .HasColumnType("datetimeoffset"); + + b.Property("Description") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ImageUrl") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("ModifiedOnUtc") + .HasColumnType("datetimeoffset"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.HasIndex("CategoryId"); + + b.ToTable("Certificates"); + }); + + modelBuilder.Entity("MBS_COMMAND.Domain.Entities.Config", b => + { + b.Property("Key") + .HasColumnType("nvarchar(450)"); + + b.Property("Value") + .HasColumnType("int"); + + b.HasKey("Key"); + + b.ToTable("Configs"); + }); + + modelBuilder.Entity("MBS_COMMAND.Domain.Entities.Feedback", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("Content") + .HasColumnType("nvarchar(max)"); + + b.Property("CreatedOnUtc") + .HasColumnType("datetimeoffset"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("IsMentor") + .HasColumnType("bit"); + + b.Property("ModifiedOnUtc") + .HasColumnType("datetimeoffset"); + + b.Property("Rating") + .HasColumnType("int"); + + b.Property("SlotId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("SlotId"); + + b.ToTable("Feedbacks"); + }); + + modelBuilder.Entity("MBS_COMMAND.Domain.Entities.Group", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("CreatedOnUtc") + .HasColumnType("datetimeoffset"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("MentorId") + .HasColumnType("uniqueidentifier"); + + b.Property("ModifiedOnUtc") + .HasColumnType("datetimeoffset"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ProjectId") + .HasColumnType("uniqueidentifier"); + + b.Property("Stack") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.HasIndex("MentorId"); + + b.HasIndex("ProjectId"); + + b.ToTable("Groups"); + }); + + modelBuilder.Entity("MBS_COMMAND.Domain.Entities.Group_Student_Mapping", b => + { + b.Property("GroupId") + .HasColumnType("uniqueidentifier"); + + b.Property("StudentId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("GroupId", "StudentId"); + + b.HasIndex("StudentId"); + + b.ToTable("group_Student_Mappings"); + }); + + modelBuilder.Entity("MBS_COMMAND.Domain.Entities.Project", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("CreatedOnUtc") + .HasColumnType("datetimeoffset"); + + b.Property("Description") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("ModifiedOnUtc") + .HasColumnType("datetimeoffset"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("Projects"); + }); + + modelBuilder.Entity("MBS_COMMAND.Domain.Entities.Schedule", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("CreatedOnUtc") + .HasColumnType("datetimeoffset"); + + b.Property("Date") + .HasColumnType("date"); + + b.Property("EndTime") + .HasColumnType("time"); + + b.Property("GroupId") + .HasColumnType("uniqueidentifier"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("MentorId") + .HasColumnType("uniqueidentifier"); + + b.Property("ModifiedOnUtc") + .HasColumnType("datetimeoffset"); + + b.Property("StartTime") + .HasColumnType("time"); + + b.Property("SubjectId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("GroupId"); + + b.HasIndex("MentorId"); + + b.HasIndex("SubjectId"); + + b.ToTable("Schedules"); + }); + + modelBuilder.Entity("MBS_COMMAND.Domain.Entities.Semester", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("CreatedOnUtc") + .HasColumnType("datetimeoffset"); + + b.Property("From") + .HasColumnType("date"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("ModifiedOnUtc") + .HasColumnType("datetimeoffset"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("To") + .HasColumnType("date"); + + b.HasKey("Id"); + + b.ToTable("Semesters"); + }); + + modelBuilder.Entity("MBS_COMMAND.Domain.Entities.Skill", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("CategoryId") + .HasColumnType("uniqueidentifier"); + + b.Property("CreatedOnUtc") + .HasColumnType("datetimeoffset"); + + b.Property("Description") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("ModifiedOnUtc") + .HasColumnType("datetimeoffset"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.HasIndex("CategoryId"); + + b.ToTable("Skills"); + }); + + modelBuilder.Entity("MBS_COMMAND.Domain.Entities.Slot", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("CreatedOnUtc") + .HasColumnType("datetimeoffset"); + + b.Property("Date") + .HasColumnType("date"); + + b.Property("EndTime") + .HasColumnType("time"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("MentorId") + .HasColumnType("uniqueidentifier"); + + b.Property("ModifiedOnUtc") + .HasColumnType("datetimeoffset"); + + b.Property("StartTime") + .HasColumnType("time"); + + b.Property("Status") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("MentorId"); + + b.ToTable("Slots"); + }); + + modelBuilder.Entity("MBS_COMMAND.Domain.Entities.Subject", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("CreatedOnUtc") + .HasColumnType("datetimeoffset"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("ModifiedOnUtc") + .HasColumnType("datetimeoffset"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("SemesterId") + .HasColumnType("uniqueidentifier"); + + b.Property("Status") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("SemesterId"); + + b.ToTable("Subjects"); + }); + + modelBuilder.Entity("MBS_COMMAND.Domain.Entities.Transaction", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("CreatedOnUtc") + .HasColumnType("datetimeoffset"); + + b.Property("Date") + .HasColumnType("date"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("ModifiedOnUtc") + .HasColumnType("datetimeoffset"); + + b.Property("SlotId") + .HasColumnType("uniqueidentifier"); + + b.Property("Status") + .HasColumnType("int"); + + b.Property("UserId") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("SlotId"); + + b.HasIndex("UserId"); + + b.ToTable("Transactions"); + }); + modelBuilder.Entity("MBS_COMMAND.Persistence.Outbox.OutboxMessage", b => { b.Property("Id") @@ -52,6 +505,140 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.ToTable("OutboxMessages", (string)null); }); + + modelBuilder.Entity("MBS_AUTHORIZATION.Domain.Entities.User", b => + { + b.HasOne("MBS_AUTHORIZATION.Domain.Entities.User", "Mentor") + .WithMany() + .HasForeignKey("MentorId"); + + b.Navigation("Mentor"); + }); + + modelBuilder.Entity("MBS_COMMAND.Domain.Entities.Certificate", b => + { + b.HasOne("MBS_COMMAND.Domain.Entities.Category", "Category") + .WithMany() + .HasForeignKey("CategoryId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Category"); + }); + + modelBuilder.Entity("MBS_COMMAND.Domain.Entities.Feedback", b => + { + b.HasOne("MBS_COMMAND.Domain.Entities.Slot", "Slot") + .WithMany() + .HasForeignKey("SlotId"); + + b.Navigation("Slot"); + }); + + modelBuilder.Entity("MBS_COMMAND.Domain.Entities.Group", b => + { + b.HasOne("MBS_AUTHORIZATION.Domain.Entities.User", "Mentor") + .WithMany() + .HasForeignKey("MentorId"); + + b.HasOne("MBS_COMMAND.Domain.Entities.Project", "Project") + .WithMany() + .HasForeignKey("ProjectId"); + + b.Navigation("Mentor"); + + b.Navigation("Project"); + }); + + modelBuilder.Entity("MBS_COMMAND.Domain.Entities.Group_Student_Mapping", b => + { + b.HasOne("MBS_COMMAND.Domain.Entities.Group", "Group") + .WithMany() + .HasForeignKey("GroupId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("MBS_AUTHORIZATION.Domain.Entities.User", "Student") + .WithMany() + .HasForeignKey("StudentId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Group"); + + b.Navigation("Student"); + }); + + modelBuilder.Entity("MBS_COMMAND.Domain.Entities.Schedule", b => + { + b.HasOne("MBS_COMMAND.Domain.Entities.Group", "Group") + .WithMany() + .HasForeignKey("GroupId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("MBS_AUTHORIZATION.Domain.Entities.User", "Mentor") + .WithMany() + .HasForeignKey("MentorId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("MBS_COMMAND.Domain.Entities.Subject", "Subject") + .WithMany() + .HasForeignKey("SubjectId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Group"); + + b.Navigation("Mentor"); + + b.Navigation("Subject"); + }); + + modelBuilder.Entity("MBS_COMMAND.Domain.Entities.Skill", b => + { + b.HasOne("MBS_COMMAND.Domain.Entities.Category", "Category") + .WithMany() + .HasForeignKey("CategoryId"); + + b.Navigation("Category"); + }); + + modelBuilder.Entity("MBS_COMMAND.Domain.Entities.Slot", b => + { + b.HasOne("MBS_AUTHORIZATION.Domain.Entities.User", "Mentor") + .WithMany() + .HasForeignKey("MentorId"); + + b.Navigation("Mentor"); + }); + + modelBuilder.Entity("MBS_COMMAND.Domain.Entities.Subject", b => + { + b.HasOne("MBS_COMMAND.Domain.Entities.Semester", "Semester") + .WithMany() + .HasForeignKey("SemesterId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Semester"); + }); + + modelBuilder.Entity("MBS_COMMAND.Domain.Entities.Transaction", b => + { + b.HasOne("MBS_COMMAND.Domain.Entities.Slot", "Slot") + .WithMany() + .HasForeignKey("SlotId"); + + b.HasOne("MBS_AUTHORIZATION.Domain.Entities.User", "User") + .WithMany() + .HasForeignKey("UserId"); + + b.Navigation("Slot"); + + b.Navigation("User"); + }); #pragma warning restore 612, 618 } }