- Introduced new tables `timeline_footprints` and `timeline_activities` to manage employee location data and activity records. - Updated `company_settings` to include `gps_interval_seconds` and `checkout_warning_radius_meters` for enhanced tracking configuration. - Implemented foreign key constraints to ensure data integrity between new tables and existing `employees`, `customers`, and `visits` tables. - Created services and controllers for handling timeline activities and footprints, including ingestion and retrieval of data. - Enhanced DTOs and validation logic to support new fields and ensure correct data formats in API requests. - Added unit and integration tests to validate the new functionalities and ensure proper handling of timeline records. - Created migration scripts to apply the necessary database schema changes for the new features.
21 lines
878 B
TypeScript
21 lines
878 B
TypeScript
import { bigint, integer, pgTable, uuid } from 'drizzle-orm/pg-core';
|
|
import { primaryEntityColumns } from './primary-entity-columns';
|
|
import { users } from './schema';
|
|
|
|
/**
|
|
* Company-wide operational settings (singleton aggregate).
|
|
*/
|
|
export const companySettings = pgTable('company_settings', {
|
|
id: uuid('id').defaultRandom().notNull().primaryKey(),
|
|
cycleStartDate: bigint('cycle_start_date', { mode: 'number' }).notNull(),
|
|
checkInRadiusMeters: integer('check_in_radius_meters').notNull().default(100),
|
|
gpsIntervalSeconds: integer('gps_interval_seconds').notNull().default(5),
|
|
checkoutWarningRadiusMeters: integer('checkout_warning_radius_meters')
|
|
.notNull()
|
|
.default(200),
|
|
...primaryEntityColumns(users),
|
|
});
|
|
|
|
export type CompanySettingsRow = typeof companySettings.$inferSelect;
|
|
export type NewCompanySettingsRow = typeof companySettings.$inferInsert;
|