Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

QUESTION: How to handle Schema changes? #24

Open
jfbaro opened this issue Feb 15, 2022 · 0 comments
Open

QUESTION: How to handle Schema changes? #24

jfbaro opened this issue Feb 15, 2022 · 0 comments

Comments

@jfbaro
Copy link

jfbaro commented Feb 15, 2022

Hello there!

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) without breaking my existing queries? SQL:2016

Are there any best practices or strategies to avoid all this complexity with these temporal tables + schema migration?

Any help would be much appreciated.

P.S: I didn't find the RIGHT place to post a question to the community. If that's the wrong place, please feel free to remove it. (sorry)

Thanks

@jfbaro jfbaro changed the title QUESTION: How to hanble Schema changes? QUESTION: How to handle Schema changes? Feb 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant