Imagine I have a temporal table for personal information:
- UUID (varchar)
- main_document (varchar)
- name (varchar)
- DoB (timestamp)
- genre (varchar)
- address (varchar)
- salary (decimal)
at T1 I run a schema migration and add a new column, from now on the table has:
- UUID (varchar)
- main_document (varchar)
- name (varchar)
- DoB (timestamp)
- genre (varchar)
- address (varchar)
- salary (decimal)
- EMAIL (varchar)*
Then at T2 I run another schema migration and change the data type of main_document to NUMBER.
- UUID (varchar)
- main_document (NUMBER)*
- name (varchar)
- DoB (timestamp)
- genre (varchar)
- address (varchar)
- salary (decimal)
- email (varchar)
Then at T3 I run another schema migration and remove the genre column
- UUID (varchar)
- main_document (number)
- name (varchar)
- DoB (timestamp)
- ---------------*
- address (varchar)
- salary (decimal)
- email (varchar)
Then at T4 I run another schema migration and add the genre column, but now it has the data type NUMBER.
- UUID (varchar)
- main_document (number)
- name (varchar)
- DoB (timestamp)
- genre (NUMBER)*
- address (varchar)
- salary (decimal)
- email (varchar)
How can I query my DB (going back in time) if the schema has changed on T1, T2, T3, T4, etc?
Like, we are at (wall time) T4 and run: select * from people AS OF T3, what should be returned? Is it really time travel?
Are there any best practices or strategies to avoid all this complexity with these temporal tables + schema migration?
Any help would be much appreciated.
Thanks