-
Notifications
You must be signed in to change notification settings - Fork 143
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
Proposal: Change migration strategy for database object SQL #11696
Comments
I really like this @bferguso. I mentioned at standup today my interest in ensuring there's a pathway to use whatever pattern we land on here with existing packages like (Reason: the result of The minor suggestion I would have on the implementation sketch would be to skip the concat'ing of all the strings together and instead return an array, since it's simple enough for a user to concat themselves with |
@jacobtylerwalls - Thanks for having a look. re: the concatenating - I went back and forth on this, and I got caught (probably overthinking) about how to manage the granularity of statements, and landed on the idea that if you wanted to run them independently then that could be done by either writing separate migrations, thereby putting each statement in it's own transaction, or by implementing one-by-one execution by using it like this:
Having said all that, I agree that it might be cleaner and give the user more control over how each statement is processed, and the more I think about it the less of an opinion I have. I guess another question is if we even want to use lists of files within the migrations or if that's opening a can of worms we'd rather leave unopened. |
Background
With the current patterm for deploying database objects (table, view, function, etc.), where the SQL is directly embedded in the migration
.py
files, often with several objects embedded in a single file, it can be quite difficult to trace the changes made to those objects over time.It would be nice to externalize SQL for those database objects (not 1-off SQL statements, but the SQL that represents database objects) so that it can:
Proposed Solution
migrations/sql
sql/
directory, one object per filevYYYY.MM.DD.SEQ__object_name.sql
, eg:v2024.12.17.001__my_function_call.sql
sql/2024
,sql/2025
..)A PR for this could target v8.
The text was updated successfully, but these errors were encountered: