3.0 KiB
3.0 KiB
Data Migration Plan: Employee, Shift, and Attendance
Executive Summary
This document outlines a structured plan to import historical Employee, Shift, and Attendance records from the legacy data dump (rame_seb.sql) into the current HRM system. Based on user directives, we will replicate the legacy data as closely as possible to the new relational structure.
Architectural Approach & Data Mapping
1. Employee Details
- Source: Legacy
userstable. - Target: Current
usersandemployeestables. - Approach:
- We will read the legacy
usersrows. - For each row, create a
Useridentity for authentication. - Password Rule: Explicitly set all imported users' passwords to
123456(hashed using Laravel'sHash::make('123456')) to ensure smooth initial access. - Create the related
Employeeprofile using the legacy HR details (phone,address, etc.), maintaining the mapping viauser_id.
- We will read the legacy
2. Shifts (The 48-Shift Strategy)
- Source: Legacy
shiftstable (contains ~48 half-hour interval shifts covering the 24-hour cycle, e.g.,OPS 12:00AM-09:00AM). - Target: Current
shiftstable. - Approach:
- Direct Replication: We will import all 48 distinct shift templates exactly as they are defined in the legacy system.
- Scheduling: Since the legacy shifts are universally enabled for all 7 days (
sundaythroughsaturday=1), we do not need complex roster logic. We will simply migrate thestart_time,end_time, andis_night_shiftlogic into our newShifttemplates, making them immediately available for assignment to Employees.
3. Attendance
- Source: Legacy
attendancestable. - Target: Current
attendance_recordstable. - Approach:
- Read the raw
check_in_time,check_out_time, andworking_hoursfrom the legacy database. - Link them to the newly generated
EmployeeID rather than the old legacy User ID. - Map legacy attendance statuses (
present,leave, etc.) to the new system's properties. - "Just Copy" strategy: Orphaned records (if any) will still be imported if the related user exists, preserving historical attendance integrity.
- Read the raw
Task Breakdown / Execution Plan
- Database Preparation:
- Load
rame_seb.sqlinto a temporary secondary database connection in Laravel (e.g.,legacy_db).
- Load
- Shift Importer:
- Write a Seeder/Command to insert the 48 shifts into the
shiftstable. - Retain legacy
idmappings to properly link attendance records later.
- Write a Seeder/Command to insert the 48 shifts into the
- Employee Importer:
- Write a Command to stream legacy users.
- Insert into
users(password:123456). - Insert into
employees(associate with their legacy defaultshift_id).
- Attendance Importer:
- Write a Command to fetch all legacy
attendances. - Remap IDs to the new structure and insert them sequentially into
attendance_records.
- Write a Command to fetch all legacy
This plan is ready for execution. Run /create or confirm to proceed with writing the import scripts.