Changeset e882b92 for ChapterX.Infrastructure/Data
Legend:
- Unmodified
- Added
- Removed
-
ChapterX.Infrastructure/Data/DataContext/ApplicationDbContext.cs
ra6e33d1 re882b92 19 19 public DbSet<Likes> Likes { get; init; } 20 20 public DbSet<Collaboration> Collaborations { get; init; } 21 public DbSet<Notify> Notifies { get; init; }22 21 public DbSet<AISuggestion> AISuggestions { get; init; } 23 22 public DbSet<Admin> Admins { get; init; } … … 26 25 public DbSet<HasGenre> HasGenres { get; init; } 27 26 public DbSet<NeedApproval> NeedApprovals { get; init; } 28 public DbSet<Status> Statuses { get; init; }29 public DbSet<ContentType> ContentTypes { get; init; }30 public DbSet<SuggestionType> SuggestionTypes { get; init; }31 public DbSet<Roles> Roles { get; init; }32 public DbSet<PermissionLevel> PermissionLevels { get; init; }33 27 34 28 public Task<IDbContextTransaction> BeginTransactionAsync(CancellationToken cancellationToken = default) … … 60 54 e.HasKey(x => x.Id); 61 55 e.Property(x => x.Id).HasColumnName("user_id"); 56 e.Property(x => x.AssignedAt).HasColumnName("assigned_at"); 62 57 e.HasOne(x => x.User).WithOne(u => u.Admin).HasForeignKey<Admin>(x => x.Id); 63 58 }); … … 69 64 e.HasKey(x => x.Id); 70 65 e.Property(x => x.Id).HasColumnName("user_id"); 66 e.Property(x => x.JoinedAt).HasColumnName("joined_at"); 71 67 e.HasOne(x => x.User).WithOne(u => u.RegularUser).HasForeignKey<RegularUser>(x => x.Id); 72 68 }); … … 78 74 e.HasKey(x => x.Id); 79 75 e.Property(x => x.Id).HasColumnName("user_id"); 76 e.Property(x => x.Bio).HasColumnName("bio"); 80 77 e.HasOne(x => x.User).WithOne(u => u.Writer).HasForeignKey<Writer>(x => x.Id); 81 78 }); … … 92 89 e.Property(x => x.Image).HasColumnName("image"); 93 90 e.Property(x => x.Content).HasColumnName("story_content"); 91 e.Property(x => x.Status).HasColumnName("status"); 94 92 e.Property(x => x.UserId).HasColumnName("user_id"); 95 93 e.Property(x => x.CreatedAt).HasColumnName("story_created_at"); 96 94 e.Property(x => x.UpdatedAt).HasColumnName("story_updated_at"); 97 95 e.HasOne(x => x.Writer).WithMany(w => w.Stories).HasForeignKey(x => x.UserId); 98 });99 100 // STATUS101 modelBuilder.Entity<Status>(e =>102 {103 e.ToTable("status");104 e.HasKey(x => new { x.StoryId, x.StatusValue });105 e.Ignore(x => x.Id);106 e.Property(x => x.StoryId).HasColumnName("story_id");107 e.Property(x => x.StatusValue).HasColumnName("status");108 e.HasOne(x => x.Story).WithMany(s => s.Statuses).HasForeignKey(x => x.StoryId);109 96 }); 110 97 … … 158 145 e.Property(x => x.UserId).HasColumnName("user_id"); 159 146 e.Property(x => x.StoryId).HasColumnName("story_id"); 160 e.Property(x => x. CreatedAt).HasColumnName("like_created_at");147 e.Property(x => x.LikedAt).HasColumnName("liked_at"); 161 148 e.HasOne(x => x.User).WithMany(u => u.Likes).HasForeignKey(x => x.UserId); 162 149 e.HasOne(x => x.Story).WithMany(s => s.Likes).HasForeignKey(x => x.StoryId); … … 213 200 e.Property(x => x.Id).HasColumnName("notification_id"); 214 201 e.Property(x => x.Content).HasColumnName("notification_content"); 202 e.Property(x => x.ContentType).HasColumnName("content_type"); 215 203 e.Property(x => x.IsRead).HasColumnName("is_read"); 204 e.Property(x => x.Link).HasColumnName("link"); 205 e.Property(x => x.UserId).HasColumnName("user_id"); 206 e.Property(x => x.StoryId).HasColumnName("story_id"); 216 207 e.Property(x => x.CreatedAt).HasColumnName("notification_created_at"); 217 e.Property(x => x.RecipientUserId).HasColumnName("recipient_user_id"); 218 e.Property(x => x.Type).HasColumnName("type"); 219 e.Property(x => x.Link).HasColumnName("link"); 220 }); 221 222 // CONTENT_TYPE 223 modelBuilder.Entity<ContentType>(e => 224 { 225 e.ToTable("content_type"); 226 e.HasKey(x => new { x.NotificationId, x.ContentTypeValue }); 227 e.Ignore(x => x.Id); 228 e.Property(x => x.NotificationId).HasColumnName("notification_id"); 229 e.Property(x => x.ContentTypeValue).HasColumnName("content_type"); 230 e.HasOne(x => x.Notification).WithMany(n => n.ContentTypes).HasForeignKey(x => x.NotificationId); 231 }); 232 233 // NOTIFY 234 modelBuilder.Entity<Notify>(e => 235 { 236 e.ToTable("notify"); 237 e.HasKey(x => new { x.UserId, x.StoryId, x.NotificationId }); 238 e.Ignore(x => x.Id); 239 e.Property(x => x.UserId).HasColumnName("user_id"); 240 e.Property(x => x.StoryId).HasColumnName("story_id"); 241 e.Property(x => x.NotificationId).HasColumnName("notification_id"); 242 e.HasOne(x => x.User).WithMany(u => u.Notifies).HasForeignKey(x => x.UserId); 243 e.HasOne(x => x.Story).WithMany(s => s.Notifies).HasForeignKey(x => x.StoryId); 244 e.HasOne(x => x.Notification).WithMany(n => n.Notifies).HasForeignKey(x => x.NotificationId); 208 e.HasOne(x => x.User).WithMany(u => u.Notifications).HasForeignKey(x => x.UserId); 209 e.HasOne(x => x.Story).WithMany(s => s.Notifications).HasForeignKey(x => x.StoryId) 210 .IsRequired(false).OnDelete(DeleteBehavior.SetNull); 245 211 }); 246 212 … … 253 219 e.Property(x => x.OriginalText).HasColumnName("original_text"); 254 220 e.Property(x => x.SuggestedText).HasColumnName("suggested_text"); 221 e.Property(x => x.SuggestionType).HasColumnName("suggestion_type"); 255 222 e.Property(x => x.Accepted).HasColumnName("accepted"); 256 223 e.Property(x => x.CreatedAt).HasColumnName("suggestion_created_at"); … … 258 225 e.Property(x => x.StoryId).HasColumnName("story_id"); 259 226 e.HasOne(x => x.Story).WithMany(s => s.AISuggestions).HasForeignKey(x => x.StoryId); 260 });261 262 // SUGGESTION_TYPE263 modelBuilder.Entity<SuggestionType>(e =>264 {265 e.ToTable("suggestion_type");266 e.HasKey(x => new { x.SuggestionId, x.SuggestionTypeValue });267 e.Ignore(x => x.Id);268 e.Property(x => x.SuggestionId).HasColumnName("suggestion_id");269 e.Property(x => x.SuggestionTypeValue).HasColumnName("suggestion_type");270 e.HasOne(x => x.AISuggestion).WithMany(a => a.SuggestionTypes).HasForeignKey(x => x.SuggestionId);271 227 }); 272 228 … … 293 249 e.Property(x => x.UserId).HasColumnName("user_id"); 294 250 e.Property(x => x.StoryId).HasColumnName("story_id"); 251 e.Property(x => x.Role).HasColumnName("role"); 252 e.Property(x => x.PermissionLevel).HasColumnName("permission_level"); 295 253 e.Property(x => x.CreatedAt).HasColumnName("collab_created_at"); 296 254 e.HasOne(x => x.User).WithMany(u => u.Collaborations).HasForeignKey(x => x.UserId); 297 255 e.HasOne(x => x.Story).WithMany(s => s.Collaborations).HasForeignKey(x => x.StoryId); 298 256 }); 299 300 // ROLES301 modelBuilder.Entity<Roles>(e =>302 {303 e.ToTable("roles");304 e.HasKey(x => new { x.UserId, x.StoryId, x.RoleValue });305 e.Ignore(x => x.Id);306 e.Property(x => x.UserId).HasColumnName("user_id");307 e.Property(x => x.StoryId).HasColumnName("story_id");308 e.Property(x => x.RoleValue).HasColumnName("roles");309 });310 311 // PERMISSION_LEVEL312 modelBuilder.Entity<PermissionLevel>(e =>313 {314 e.ToTable("permission_level");315 e.HasKey(x => new { x.UserId, x.StoryId, x.Level });316 e.Ignore(x => x.Id);317 e.Property(x => x.UserId).HasColumnName("user_id");318 e.Property(x => x.StoryId).HasColumnName("story_id");319 e.Property(x => x.Level).HasColumnName("permission_level");320 });321 257 } 322 258 }
Note:
See TracChangeset
for help on using the changeset viewer.
