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:
@@ -9,13 +9,10 @@ import {
|
||||
numeric,
|
||||
date,
|
||||
} from 'drizzle-orm/pg-core'
|
||||
import { companies, locations } from './stores.js'
|
||||
import { locations } from './stores.js'
|
||||
|
||||
export const categories = pgTable('category', {
|
||||
id: uuid('id').primaryKey().defaultRandom(),
|
||||
companyId: uuid('company_id')
|
||||
.notNull()
|
||||
.references(() => companies.id),
|
||||
parentId: uuid('parent_id'),
|
||||
name: varchar('name', { length: 255 }).notNull(),
|
||||
description: text('description'),
|
||||
@@ -27,9 +24,6 @@ export const categories = pgTable('category', {
|
||||
|
||||
export const suppliers = pgTable('supplier', {
|
||||
id: uuid('id').primaryKey().defaultRandom(),
|
||||
companyId: uuid('company_id')
|
||||
.notNull()
|
||||
.references(() => companies.id),
|
||||
name: varchar('name', { length: 255 }).notNull(),
|
||||
contactName: varchar('contact_name', { length: 255 }),
|
||||
email: varchar('email', { length: 255 }),
|
||||
@@ -49,9 +43,6 @@ export const suppliers = pgTable('supplier', {
|
||||
|
||||
export const products = pgTable('product', {
|
||||
id: uuid('id').primaryKey().defaultRandom(),
|
||||
companyId: uuid('company_id')
|
||||
.notNull()
|
||||
.references(() => companies.id),
|
||||
locationId: uuid('location_id').references(() => locations.id),
|
||||
sku: varchar('sku', { length: 100 }),
|
||||
upc: varchar('upc', { length: 100 }),
|
||||
@@ -79,9 +70,6 @@ export const inventoryUnits = pgTable('inventory_unit', {
|
||||
productId: uuid('product_id')
|
||||
.notNull()
|
||||
.references(() => products.id),
|
||||
companyId: uuid('company_id')
|
||||
.notNull()
|
||||
.references(() => companies.id),
|
||||
locationId: uuid('location_id').references(() => locations.id),
|
||||
serialNumber: varchar('serial_number', { length: 255 }),
|
||||
condition: varchar('condition', { length: 100 }).notNull().default('new'),
|
||||
@@ -112,9 +100,6 @@ export type Supplier = typeof suppliers.$inferSelect
|
||||
export type SupplierInsert = typeof suppliers.$inferInsert
|
||||
export const stockReceipts = pgTable('stock_receipt', {
|
||||
id: uuid('id').primaryKey().defaultRandom(),
|
||||
companyId: uuid('company_id')
|
||||
.notNull()
|
||||
.references(() => companies.id),
|
||||
locationId: uuid('location_id').references(() => locations.id),
|
||||
productId: uuid('product_id')
|
||||
.notNull()
|
||||
@@ -136,9 +121,6 @@ export const priceHistory = pgTable('price_history', {
|
||||
productId: uuid('product_id')
|
||||
.notNull()
|
||||
.references(() => products.id),
|
||||
companyId: uuid('company_id')
|
||||
.notNull()
|
||||
.references(() => companies.id),
|
||||
previousPrice: numeric('previous_price', { precision: 10, scale: 2 }),
|
||||
newPrice: numeric('new_price', { precision: 10, scale: 2 }).notNull(),
|
||||
previousMinPrice: numeric('previous_min_price', { precision: 10, scale: 2 }),
|
||||
@@ -158,9 +140,6 @@ export const consignmentDetails = pgTable('consignment_detail', {
|
||||
productId: uuid('product_id')
|
||||
.notNull()
|
||||
.references(() => products.id),
|
||||
companyId: uuid('company_id')
|
||||
.notNull()
|
||||
.references(() => companies.id),
|
||||
consignorAccountId: uuid('consignor_account_id').notNull(),
|
||||
commissionPercent: numeric('commission_percent', { precision: 5, scale: 2 }).notNull(),
|
||||
minPrice: numeric('min_price', { precision: 10, scale: 2 }),
|
||||
|
||||
Reference in New Issue
Block a user