You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've generated scripts for all of my VIEWS and FUNCTIONS, one file per object.
But now we have a problem - we can't just execute them in alphabetical order on a clean DB because of dependencies between the objects (e.g. one view depends on another that is a alphabetically after it, or a view depends on an FUNCTION or a T-V-FUNCTION on a view etc.).
Does this mean we have to manually rename the files to add numerical prefixes? And is that enough - e.g. how can I tell grate to run the script to create view ViewFoo after the function FuncBar which it depends on, but the script to create Function FuncFoo after the script to create view ViewBar, which it depends on?
Even for updates there are likely to be issues - e.g. we need to modify ViewFoo to add a column, and modify ViewBar which uses ViewFoo to refer to this new column.
It seems surprising that a tool like grate has no built-in capacity for handling this (i.e. automatically detecting dependencies and executing the scripts in the necessary order), so what are my options?
Edit: it occurred to me one solution would be to simply execute grate in such a way that it ignored errors on individual scripts, and run them in a loop until they all succeed. I actually know for a fact it would currently require 3 such runs (because we have 1 view that depends on a view with an alphabetically-later name, which itself depends on another view with an alphabetically-later name). But I can't see any option in grate to continue running scripts even after error...
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I've generated scripts for all of my VIEWS and FUNCTIONS, one file per object.
But now we have a problem - we can't just execute them in alphabetical order on a clean DB because of dependencies between the objects (e.g. one view depends on another that is a alphabetically after it, or a view depends on an FUNCTION or a T-V-FUNCTION on a view etc.).
Does this mean we have to manually rename the files to add numerical prefixes? And is that enough - e.g. how can I tell grate to run the script to create view ViewFoo after the function FuncBar which it depends on, but the script to create Function FuncFoo after the script to create view ViewBar, which it depends on?
Even for updates there are likely to be issues - e.g. we need to modify ViewFoo to add a column, and modify ViewBar which uses ViewFoo to refer to this new column.
It seems surprising that a tool like grate has no built-in capacity for handling this (i.e. automatically detecting dependencies and executing the scripts in the necessary order), so what are my options?
Edit: it occurred to me one solution would be to simply execute grate in such a way that it ignored errors on individual scripts, and run them in a loop until they all succeed. I actually know for a fact it would currently require 3 such runs (because we have 1 view that depends on a view with an alphabetically-later name, which itself depends on another view with an alphabetically-later name). But I can't see any option in grate to continue running scripts even after error...
Beta Was this translation helpful? Give feedback.
All reactions