M1: OrgBoard — organizations, teams, seats, the board & cartable

OrgBoard module (references SharedKernel only; RBAC via ICurrentUser/IPermissionService):
- Organization, Team, Seat (human/open/ai), WorkItem (board task: type, status, assignee,
  parent) entities; internal OrgBoardDbContext (schema "orgboard") + InitialOrgBoard
  migration; design-time factory. (WorkItem avoids the System.Threading.Tasks.Task clash.)
- Endpoints under /api/orgboard, every mutation permission-checked at the scope chain
  [team, org]: POST /organizations, POST/GET /teams, POST /tasks, GET /board (columns
  backlog->in progress->in review->done), PATCH /tasks/{id}/move, /assign, GET /cartable.

Test isolation: integration tests now use IClassFixture so each class gets its own
pgvector container (the bootstrap-once rule made a shared container collide).

Verified: build green; ArchitectureTests 8/8 (OrgBoard references only SharedKernel);
IntegrationTests 12/12 incl. a new board flow — owner sets up org+team, creates/moves/
assigns a task, sees it on the board and in the cartable; an invited Member can view the
board but is 403'd from creating a team.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
soroush.asadi
2026-06-09 11:58:20 +03:30
parent 61991bf6cd
commit e1911f58b1
18 changed files with 1137 additions and 23 deletions
@@ -0,0 +1,55 @@
using Microsoft.EntityFrameworkCore;
using TeamUp.Modules.OrgBoard.Domain;
using TeamUp.SharedKernel.Persistence;
namespace TeamUp.Modules.OrgBoard.Persistence;
internal sealed class OrgBoardDbContext(DbContextOptions<OrgBoardDbContext> options)
: DbContext(options), IModuleDbContext
{
public DbSet<Organization> Organizations => Set<Organization>();
public DbSet<Team> Teams => Set<Team>();
public DbSet<Seat> Seats => Set<Seat>();
public DbSet<WorkItem> WorkItems => Set<WorkItem>();
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.HasDefaultSchema("orgboard");
modelBuilder.Entity<Organization>(organization =>
{
organization.ToTable("organizations");
organization.HasKey(o => o.Id);
organization.Property(o => o.Name).HasMaxLength(200).IsRequired();
});
modelBuilder.Entity<Team>(team =>
{
team.ToTable("teams");
team.HasKey(t => t.Id);
team.Property(t => t.Name).HasMaxLength(200).IsRequired();
team.HasIndex(t => t.OrganizationId);
});
modelBuilder.Entity<Seat>(seat =>
{
seat.ToTable("seats");
seat.HasKey(s => s.Id);
seat.Property(s => s.RoleName).HasMaxLength(120).IsRequired();
seat.Property(s => s.State).HasConversion<string>().HasMaxLength(16);
seat.HasIndex(s => s.TeamId);
});
modelBuilder.Entity<WorkItem>(workItem =>
{
workItem.ToTable("work_items");
workItem.HasKey(w => w.Id);
workItem.Property(w => w.Title).HasMaxLength(300).IsRequired();
workItem.Property(w => w.Type).HasConversion<string>().HasMaxLength(16);
workItem.Property(w => w.Status).HasConversion<string>().HasMaxLength(16);
workItem.Property(w => w.AssigneeKind).HasConversion<string>().HasMaxLength(16);
workItem.HasIndex(w => w.TeamId);
workItem.HasIndex(w => new { w.AssigneeKind, w.AssigneeId });
});
}
}