Add user and employee management enhancements with database schema updates

- Introduced new columns `status`, `created_by`, and `updated_by` in the `users` table to track user status and ownership.
- Updated the `employees` table to include a foreign key reference to the `users` table via `user_id`.
- Created migration script `0012_users_primary.sql` to apply these changes to the database schema.
- Enhanced the `EmployeesService` and `EmployeesRepository` to support user assignments and related data retrieval.
- Updated DTOs and service methods to reflect the new user and employee relationships.
- Added unit tests to validate the new functionality and ensure data integrity.
- Modified existing controllers to accommodate the new fields and relationships in user and employee management.
This commit is contained in:
shancheas
2026-08-26 15:29:18 +07:00
parent f635ebeda0
commit 8a61c94078
50 changed files with 2175 additions and 401 deletions
+16 -15
View File
@@ -13,6 +13,7 @@ import {
users,
} from '../src/database/schema';
import { PRIVILEGE_ACTIONS } from '../src/modules/privileges/privilege-action';
import { registerAndActivate } from './helpers/activate-user';
describe('Sales invoices (e2e)', () => {
let app: INestApplication<App>;
@@ -37,21 +38,21 @@ describe('Sales invoices (e2e)', () => {
await app.init();
db = app.get(DRIZZLE);
const adminReg = await request(app.getHttpServer())
.post('/auth/register')
.send({ username: `si_admin_${suffix}`, password })
.expect(201);
token = (adminReg.body as { accessToken: string }).accessToken;
const adminMe = await request(app.getHttpServer())
.get('/auth/me')
.set('Authorization', `Bearer ${token}`)
.expect(200);
const adminUserId = (adminMe.body as { id: string }).id;
const otherReg = await request(app.getHttpServer())
.post('/auth/register')
.send({ username: `si_other_${suffix}`, password })
.expect(201);
otherToken = (otherReg.body as { accessToken: string }).accessToken;
const admin = await registerAndActivate(
app,
db,
`si_admin_${suffix}`,
password,
);
token = admin.accessToken;
const adminUserId = admin.userId;
const other = await registerAndActivate(
app,
db,
`si_other_${suffix}`,
password,
);
otherToken = other.accessToken;
const now = Date.now();
const [priv] = await db