Remove multi-tenant company_id scoping from entire codebase
Drop company_id column from all 22 domain tables via migration. Remove companyId from JWT payload, auth plugins, all service method signatures (~215 occurrences), all route handlers (~105 occurrences), test runner, test suites, and frontend auth store/types. The company table stays as store settings (name, timezone). Tenant isolation in a SaaS deployment would be at the database level (one DB per customer) not the application level. All 107 API tests pass. Zero TSC errors across all packages.
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import type { FastifyInstance } from 'fastify'
|
||||
import { buildApp } from '../main.js'
|
||||
import { sql, eq, and } from 'drizzle-orm'
|
||||
import { sql, eq } from 'drizzle-orm'
|
||||
import { companies, locations } from '../db/schema/stores.js'
|
||||
import { UnitStatusService, ItemConditionService } from '../services/lookup.service.js'
|
||||
import { RbacService } from '../services/rbac.service.js'
|
||||
@@ -42,12 +42,12 @@ export async function seedTestCompany(app: FastifyInstance): Promise<void> {
|
||||
name: 'Test Location',
|
||||
})
|
||||
|
||||
await UnitStatusService.seedForCompany(app.db, TEST_COMPANY_ID)
|
||||
await ItemConditionService.seedForCompany(app.db, TEST_COMPANY_ID)
|
||||
await UnitStatusService.seedDefaults(app.db)
|
||||
await ItemConditionService.seedDefaults(app.db)
|
||||
|
||||
// Seed RBAC permissions and default roles
|
||||
await RbacService.seedPermissions(app.db)
|
||||
await RbacService.seedRolesForCompany(app.db, TEST_COMPANY_ID)
|
||||
await RbacService.seedDefaultRoles(app.db)
|
||||
}
|
||||
|
||||
export async function registerAndLogin(
|
||||
@@ -80,7 +80,7 @@ export async function registerAndLogin(
|
||||
const [adminRole] = await app.db
|
||||
.select()
|
||||
.from(roles)
|
||||
.where(and(eq(roles.companyId, TEST_COMPANY_ID), eq(roles.slug, 'admin')))
|
||||
.where(eq(roles.slug, 'admin'))
|
||||
.limit(1)
|
||||
|
||||
if (adminRole) {
|
||||
|
||||
Reference in New Issue
Block a user