Skip to content

Ability to automatically run dependent scripts in correct order #631

@wizofaus

Description

@wizofaus

Is your feature request related to a problem? Please describe.
Currently if I have a SQL script for one view "bar" with the name "dbo.bar.view.sql" that depends on another view "foo" (defined in dbo.foo.view.sql), running the former can fail if the latter doesn't exist yet or have the right columns.
This can also happen between views and functions (both can depend on the column definitions/parameters of the other).

Describe the solution you'd like
If grate could detect ahead of time that view (or function) "bar" or depended on view (or function) "foo" and run the scripts in the order "foo" then "bar", that would be ideal.

Describe alternatives you've considered
The ability to keep running remaining scripts even if there is an error that's caused by a dependency issue, then grate could simply be run multiple times as needed (or even have its own ability to run on repeat until all issues resolved).
I'd also be OK if there were some way to explicitly tell Grate about dependencies between scripts.

Additional context
Scripts are all SQL server T-SQL. I'm not sure if other database engines have the same issue, but I suspect they would.

While dependencies between views can be solved just by renaming the files, it does mean for inconsistent file naming conventions. And the problem of functions that are dependent on views can't be solved like this (and yes, I do have one such case currently - it's a table-valued function that uses a couple of other views to generate the result).

Note that all my VIEW and FUNCTION scripts are CREATE OR ALTER statements.

Stored procedures are actually not a problem, BTW, as SQL server doesn't require that any referenced views/functions/secondary procedures have the expected columns/parameters.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions