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
Support ViewEntity dependency configuration #8240
Labels
Comments
zaro
pushed a commit
to zaro/typeorm
that referenced
this issue
Oct 10, 2021
Add dependsOn option to @view decorator, where dependencies can be listed. Also use these dependencies to order draop/create view correctly when generating migrations
zaro
pushed a commit
to zaro/typeorm
that referenced
this issue
Oct 10, 2021
Add dependsOn option to @view decorator, where dependencies can be listed. Also use these dependencies to order draop/create view correctly when generating migrations
7 tasks
zaro
pushed a commit
to zaro/typeorm
that referenced
this issue
Oct 10, 2021
Add dependsOn option to @view decorator, where dependencies can be listed. Also use these dependencies to order draop/create view correctly when generating migrations
pleerock
pushed a commit
that referenced
this issue
Oct 26, 2021
* feat: Add dependency configuraiton for views #8240 Add dependsOn option to @view decorator, where dependencies can be listed. Also use these dependencies to order draop/create view correctly when generating migrations * fix: Make dropping views dependencies more readable Rename some variables in viewDependencyChain in RdbmsSchemaBuilder and add more thorough comments, so its more readable. Co-authored-by: Svetlozar <ext-svetlozar@getitdone.co>
@zaro Can this issue be closed, since you've merged the PR? |
@mwanago Yes, thanks for reminding me. |
#8511 test |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Feature Description
Currently TypeORM doesn't support any way of specifying dependencies between views, which often leads to migrations being able to execute only after manual editing of the generated code.
The Problem
Suppose we have ViewA and ViewB. ViewB is using ViewA inside it's definition, so the normal order is to create first ViewA and then ViewB. Now if there is a change in ViewA, we can't execute it w/o first dropping ViewB, adjusting VIewA and then creating ViewB back. In typeorm if we edit only ViewA, the resulting migration will generate only changes for ViewA , and the migration will fail to execute because ViewB still holds a reference to ViewA and the DROP VIEW statement will fail. A workaround this will be to make also some trivial change to ViewB so it also ends up being updated in the migration. Unfortunately even this is not sufficient as the order in which these are generated is based on import order or something like this, so the DROP/CREATE statements often end up in the wrong order , e.g dropping ViewA before ViewB, and a manual edit of the migration file is needed.
With more views and dependencies the process can get quite cumbersome and error prone.
The Solution
Introduce new config for the VIewEntity decorator where we can explicitly list that a view is depending on another view and then generate the migration in the correct order based on this configuration.
Example
Considered Alternatives
None that I could think of
Relevant Database Driver(s)
Not connected to specific drivers, affects all SQL databases that support views.
Are you willing to resolve this issue by submitting a Pull Request?
The text was updated successfully, but these errors were encountered: