Dependencies between objects
drozdse1
Posts: 3
Dear Redgate Team
Is there a specific order of SQL objects (Tables, Views, Synonyms...) during the deployment process?
Does the DLM component validate the dependencies of objects during while it's deploying?
Assuming there is a view in a stored procedure. Does DLM create first the view and then the stored procedure?
Maybe my question seems to be stupid but we encountered situations where the deployment of a SP failed because the involved view was missing.
We just want to understand how DLM handles dependencies during the deployment.
Thank you
Sebastian
Is there a specific order of SQL objects (Tables, Views, Synonyms...) during the deployment process?
Does the DLM component validate the dependencies of objects during while it's deploying?
Assuming there is a view in a stored procedure. Does DLM create first the view and then the stored procedure?
Maybe my question seems to be stupid but we encountered situations where the deployment of a SP failed because the involved view was missing.
We just want to understand how DLM handles dependencies during the deployment.
Thank you
Sebastian
Comments
DLM Automation uses the SQL Compare engine, which will calculate a deployment order based on the dependencies of the objects you are trying to deploy. If a stored procedure references a view then the view should be deployed first, followed by the stored procedure.
It's possible that it could be a bug. If you're not already on the latest version of DLM Automation (2.0.7.256), I'd recommend updating just in case the SQL Compare engine contains changes that fix the problem. Here's a download link - download
If that doesn't fix the problem, would you be open to providing the view and stored procedure definitions so that I can investigate?
Redgate Software
We have tested the attached DLM Automation version (2.0.7.256) and we still encounter the mentioned problem.
The problem seems to be when we have a direct database reference to the view (for example -> select * from database.schema.viewname) then the dependency manager is not able to deploy in the right order. Please find below the attached example code. As you can see the additional column 'Dummy' was not found during the deployment. It seems that the modified view (DWHWRK.[raw].[v_ArticleGroup]) was not created before procedure.
Thank you for your answer in advance
Best Regards
Sebastian Drozdz
Ah, this explains things and I'll try to explain what is going on. We are trying to build a series of scripts. Script files don't really have a concept of database name as they are just flat files representing individual objects. When you use three part naming, the parser assumes you are referring to an external dependency that doesn't need to be built and this can result in an incorrect deployment order.
To fix this, you'll need to adjust these references to remove the database name.
Redgate Software
How about the stored procedures that might be using other database tables for merging purposes, lookups (RI checks) during ETL process? how can we deal with cross-database objects mainly during DLM schema validation? I thought about synonyms but how are these handled during schema validation, do they fail?