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:
@@ -0,0 +1,21 @@
|
||||
ALTER TABLE "users" ADD COLUMN "status" text DEFAULT 'draft' NOT NULL;
|
||||
--> statement-breakpoint
|
||||
ALTER TABLE "users" ADD COLUMN "created_by" uuid;
|
||||
--> statement-breakpoint
|
||||
ALTER TABLE "users" ADD COLUMN "updated_by" uuid;
|
||||
--> statement-breakpoint
|
||||
UPDATE "users" SET "status" = 'active', "created_by" = "id", "updated_by" = "id";
|
||||
--> statement-breakpoint
|
||||
ALTER TABLE "users" ALTER COLUMN "created_by" SET NOT NULL;
|
||||
--> statement-breakpoint
|
||||
ALTER TABLE "users" ALTER COLUMN "updated_by" SET NOT NULL;
|
||||
--> statement-breakpoint
|
||||
ALTER TABLE "users" ADD CONSTRAINT "users_created_by_users_id_fk" FOREIGN KEY ("created_by") REFERENCES "public"."users"("id") ON DELETE no action ON UPDATE no action;
|
||||
--> statement-breakpoint
|
||||
ALTER TABLE "users" ADD CONSTRAINT "users_updated_by_users_id_fk" FOREIGN KEY ("updated_by") REFERENCES "public"."users"("id") ON DELETE no action ON UPDATE no action;
|
||||
--> statement-breakpoint
|
||||
ALTER TABLE "employees" ADD COLUMN "user_id" uuid;
|
||||
--> statement-breakpoint
|
||||
ALTER TABLE "employees" ADD CONSTRAINT "employees_user_id_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."users"("id") ON DELETE set null ON UPDATE no action;
|
||||
--> statement-breakpoint
|
||||
CREATE UNIQUE INDEX "employees_user_id_unique" ON "employees" USING btree ("user_id");
|
||||
@@ -85,6 +85,13 @@
|
||||
"when": 1787559000000,
|
||||
"tag": "0011_field",
|
||||
"breakpoints": true
|
||||
},
|
||||
{
|
||||
"idx": 12,
|
||||
"version": "7",
|
||||
"when": 1787560000000,
|
||||
"tag": "0012_users_primary",
|
||||
"breakpoints": true
|
||||
}
|
||||
]
|
||||
}
|
||||
Reference in New Issue
Block a user