Current(new) structure:
Drawio | ||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
Old structure:
The old ProgrammeMembership table structure was :
...
Under the old table structure, when we need to extract a real programmeMembership, we use personId
, programmeStartDate
, programmeEndDate
, programmeId
, programmeMembershipType
fields for identification. When there’s a field above with missing data(data issue), some problems occurs for querying all curriculum memberships against a specific programmeMembership.
Why the refactoring is necessary?
Distinction between 2 entities
Current(new) table structure:
...
Steps of refactoring:
To avoid thinking of naming of some interim tables, we decided to:
1. Rename ProgrammeMembership
table to CurriculumMembership
Jira Legacy | ||||||
---|---|---|---|---|---|---|
|
Duplicate ProgrammeMembership table to a new table CurriculumMembership as a exact copy
Start writing updates to both tables
Modify all the queries (downstream services included) to use new CurriculumMembership.
Monitor for a few weeks to make sure there’re no queries to old ProgrammeMembership.
2. Rebuild new ProgrammeMemberhsip
and populate the actual data
Drop old ProgrammeMembership table, and create
...
an empty new table with necessary fields only.
Insert data via grouped curriculumMembership.
Update CurriculumMembership table with adding a new foreign key field
programmeMembershipUuid
and populate data for the foreign key.Save / Update in both new ProgrammeMembership and CurriculumMembership tables in parallel.
Interim table structure:
Drawio | ||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
Queries
Downstream services:
NDW-ETL
The queries in NDW-ETL
Jira Legacy | ||||||
---|---|---|---|---|---|---|
|
TIS-Sync
Jira Legacy | ||||||
---|---|---|---|---|---|---|
|
Assessment
Jira Legacy | ||||||
---|---|---|---|---|---|---|
|