dotnet-digital-ops/DigitalOps.Dal/MainDbScaffoldedContext.cs

277 lines
12 KiB
C#

using DigitalOps.Dal.DbEntity;
using Microsoft.EntityFrameworkCore;
namespace DigitalOps.Dal;
public partial class MainDbScaffoldedContext : DbContext
{
public MainDbScaffoldedContext()
{
}
public MainDbScaffoldedContext(DbContextOptions options)
: base(options)
{
}
public virtual DbSet<Client> Clients { get; set; }
public virtual DbSet<OidcProvider> OidcProviders { get; set; }
public virtual DbSet<Organization> Organizations { get; set; }
public virtual DbSet<OrganizationClient> OrganizationClients { get; set; }
public virtual DbSet<OrganizationUser> OrganizationUsers { get; set; }
public virtual DbSet<Project> Projects { get; set; }
public virtual DbSet<ProjectTimeEntry> ProjectTimeEntries { get; set; }
public virtual DbSet<User> Users { get; set; }
public virtual DbSet<UserOidc> UserOidcs { get; set; }
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
=> optionsBuilder.UseNpgsql("Name=Database:ConnectionString");
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.HasPostgresEnum("organization_role", new[] { "owner", "admin", "member" });
modelBuilder.Entity<Client>(entity =>
{
entity.HasKey(e => e.Id).HasName("client_pkey");
entity.ToTable("client");
entity.Property(e => e.Id).HasColumnName("id");
entity.Property(e => e.CreatedAt)
.HasDefaultValueSql("(CURRENT_TIMESTAMP AT TIME ZONE 'UTC'::text)")
.HasColumnName("created_at");
entity.Property(e => e.Name)
.HasMaxLength(255)
.HasColumnName("name");
entity.Property(e => e.UpdatedAt).HasColumnName("updated_at");
});
modelBuilder.Entity<OidcProvider>(entity =>
{
entity.HasKey(e => e.Id).HasName("oidc_provider_pkey");
entity.ToTable("oidc_provider");
entity.Property(e => e.Id).HasColumnName("id");
entity.Property(e => e.CreatedAt)
.HasDefaultValueSql("(CURRENT_TIMESTAMP AT TIME ZONE 'UTC'::text)")
.HasColumnName("created_at");
entity.Property(e => e.Issuer)
.HasMaxLength(1024)
.HasColumnName("issuer");
entity.Property(e => e.Label)
.HasMaxLength(255)
.HasColumnName("label");
entity.Property(e => e.OrganizationId).HasColumnName("organization_id");
entity.Property(e => e.UpdatedAt).HasColumnName("updated_at");
entity.HasOne(d => d.Organization).WithMany(p => p.OidcProviders)
.HasForeignKey(d => d.OrganizationId)
.OnDelete(DeleteBehavior.ClientSetNull)
.HasConstraintName("oidc_provider_organization_id_fkey");
});
modelBuilder.Entity<Organization>(entity =>
{
entity.HasKey(e => e.Id).HasName("organization_pkey");
entity.ToTable("organization");
entity.Property(e => e.Id).HasColumnName("id");
entity.Property(e => e.CreatedAt)
.HasDefaultValueSql("(CURRENT_TIMESTAMP AT TIME ZONE 'UTC'::text)")
.HasColumnName("created_at");
entity.Property(e => e.Name)
.HasMaxLength(255)
.HasColumnName("name");
entity.Property(e => e.UpdatedAt).HasColumnName("updated_at");
});
modelBuilder.Entity<OrganizationClient>(entity =>
{
entity.HasKey(e => e.Id).HasName("organization_client_pkey");
entity.ToTable("organization_client");
entity.Property(e => e.Id).HasColumnName("id");
entity.Property(e => e.ClientId).HasColumnName("client_id");
entity.Property(e => e.CreatedAt)
.HasDefaultValueSql("(CURRENT_TIMESTAMP AT TIME ZONE 'UTC'::text)")
.HasColumnName("created_at");
entity.Property(e => e.OrganizationId).HasColumnName("organization_id");
entity.Property(e => e.UpdatedAt).HasColumnName("updated_at");
entity.HasOne(d => d.Client).WithMany(p => p.OrganizationClients)
.HasForeignKey(d => d.ClientId)
.OnDelete(DeleteBehavior.ClientSetNull)
.HasConstraintName("organization_client_client_id_fkey");
entity.HasOne(d => d.Organization).WithMany(p => p.OrganizationClients)
.HasForeignKey(d => d.OrganizationId)
.OnDelete(DeleteBehavior.ClientSetNull)
.HasConstraintName("organization_client_organization_id_fkey");
});
modelBuilder.Entity<OrganizationUser>(entity =>
{
entity.HasKey(e => e.Id).HasName("organization_user_pkey");
entity.ToTable("organization_user");
entity.Property(e => e.Id).HasColumnName("id");
entity.Property(e => e.CreatedAt)
.HasDefaultValueSql("(CURRENT_TIMESTAMP AT TIME ZONE 'UTC'::text)")
.HasColumnName("created_at");
entity.Property(e => e.OrganizationId).HasColumnName("organization_id");
entity.Property(e => e.UpdatedAt).HasColumnName("updated_at");
entity.Property(e => e.UserId).HasColumnName("user_id");
entity.HasOne(d => d.Organization).WithMany(p => p.OrganizationUsers)
.HasForeignKey(d => d.OrganizationId)
.OnDelete(DeleteBehavior.ClientSetNull)
.HasConstraintName("organization_user_organization_id_fkey");
entity.HasOne(d => d.User).WithMany(p => p.OrganizationUsers)
.HasForeignKey(d => d.UserId)
.OnDelete(DeleteBehavior.ClientSetNull)
.HasConstraintName("organization_user_user_id_fkey");
});
modelBuilder.Entity<Project>(entity =>
{
entity.HasKey(e => e.Id).HasName("project_pkey");
entity.ToTable("project");
entity.Property(e => e.Id).HasColumnName("id");
entity.Property(e => e.ClientId).HasColumnName("client_id");
entity.Property(e => e.CreatedAt)
.HasDefaultValueSql("(CURRENT_TIMESTAMP AT TIME ZONE 'UTC'::text)")
.HasColumnName("created_at");
entity.Property(e => e.Name)
.HasMaxLength(255)
.HasColumnName("name");
entity.Property(e => e.UpdatedAt).HasColumnName("updated_at");
entity.HasOne(d => d.Client).WithMany(p => p.Projects)
.HasForeignKey(d => d.ClientId)
.OnDelete(DeleteBehavior.ClientSetNull)
.HasConstraintName("project_client_id_fkey");
});
modelBuilder.Entity<ProjectTimeEntry>(entity =>
{
entity.HasKey(e => e.Id).HasName("project_time_entry_pkey");
entity.ToTable("project_time_entry");
entity.Property(e => e.Id).HasColumnName("id");
entity.Property(e => e.AiDescription)
.HasMaxLength(2048)
.HasColumnName("ai_description");
entity.Property(e => e.ApprovedAt).HasColumnName("approved_at");
entity.Property(e => e.ApprovedBy).HasColumnName("approved_by");
entity.Property(e => e.CreatedAt)
.HasDefaultValueSql("(CURRENT_TIMESTAMP AT TIME ZONE 'UTC'::text)")
.HasColumnName("created_at");
entity.Property(e => e.Description)
.HasMaxLength(2048)
.HasColumnName("description");
entity.Property(e => e.EndedAt).HasColumnName("ended_at");
entity.Property(e => e.EntryUserId).HasColumnName("entry_user_id");
entity.Property(e => e.Offset).HasColumnName("offset");
entity.Property(e => e.ProjectId).HasColumnName("project_id");
entity.Property(e => e.RejectedAt).HasColumnName("rejected_at");
entity.Property(e => e.RejectedComment)
.HasMaxLength(2048)
.HasColumnName("rejected_comment");
entity.Property(e => e.StartedAt)
.HasDefaultValueSql("(CURRENT_TIMESTAMP AT TIME ZONE 'UTC'::text)")
.HasColumnName("started_at");
entity.Property(e => e.UpdatedAt).HasColumnName("updated_at");
entity.Property(e => e.UserId).HasColumnName("user_id");
entity.HasOne(d => d.ApprovedByNavigation).WithMany(p => p.ProjectTimeEntryApprovedByNavigations)
.HasForeignKey(d => d.ApprovedBy)
.HasConstraintName("project_time_entry_approved_by_fkey");
entity.HasOne(d => d.EntryUser).WithMany(p => p.ProjectTimeEntryEntryUsers)
.HasForeignKey(d => d.EntryUserId)
.OnDelete(DeleteBehavior.ClientSetNull)
.HasConstraintName("project_time_entry_entry_user_id_fkey");
entity.HasOne(d => d.Project).WithMany(p => p.ProjectTimeEntries)
.HasForeignKey(d => d.ProjectId)
.OnDelete(DeleteBehavior.ClientSetNull)
.HasConstraintName("project_time_entry_project_id_fkey");
entity.HasOne(d => d.User).WithMany(p => p.ProjectTimeEntryUsers)
.HasForeignKey(d => d.UserId)
.OnDelete(DeleteBehavior.ClientSetNull)
.HasConstraintName("project_time_entry_user_id_fkey");
});
modelBuilder.Entity<User>(entity =>
{
entity.HasKey(e => e.Id).HasName("user_pkey");
entity.ToTable("user");
entity.Property(e => e.Id).HasColumnName("id");
entity.Property(e => e.CreatedAt)
.HasDefaultValueSql("(CURRENT_TIMESTAMP AT TIME ZONE 'UTC'::text)")
.HasColumnName("created_at");
entity.Property(e => e.Email)
.HasMaxLength(255)
.HasColumnName("email");
entity.Property(e => e.FirstName)
.HasMaxLength(255)
.HasColumnName("first_name");
entity.Property(e => e.LastName)
.HasMaxLength(255)
.HasColumnName("last_name");
entity.Property(e => e.RegisteredAt).HasColumnName("registered_at");
entity.Property(e => e.UpdatedAt).HasColumnName("updated_at");
});
modelBuilder.Entity<UserOidc>(entity =>
{
entity.HasKey(e => e.Id).HasName("user_oidc_pkey");
entity.ToTable("user_oidc");
entity.Property(e => e.Id).HasColumnName("id");
entity.Property(e => e.CreatedAt)
.HasDefaultValueSql("(CURRENT_TIMESTAMP AT TIME ZONE 'UTC'::text)")
.HasColumnName("created_at");
entity.Property(e => e.Issuer)
.HasMaxLength(1024)
.HasColumnName("issuer");
entity.Property(e => e.Subject)
.HasMaxLength(255)
.HasColumnName("subject");
entity.Property(e => e.UpdatedAt).HasColumnName("updated_at");
entity.Property(e => e.UserId).HasColumnName("user_id");
entity.Property(e => e.VerifiedAt).HasColumnName("verified_at");
entity.HasOne(d => d.User).WithMany(p => p.UserOidcs)
.HasForeignKey(d => d.UserId)
.OnDelete(DeleteBehavior.ClientSetNull)
.HasConstraintName("user_oidc_user_id_fkey");
});
OnModelCreatingPartial(modelBuilder);
}
partial void OnModelCreatingPartial(ModelBuilder modelBuilder);
}