-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: performance issue in update_deprecated_advisory
- Loading branch information
Showing
3 changed files
with
43 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
use sea_orm_migration::prelude::*; | ||
|
||
#[derive(DeriveMigrationName)] | ||
pub struct Migration; | ||
|
||
#[async_trait::async_trait] | ||
impl MigrationTrait for Migration { | ||
async fn up(&self, manager: &SchemaManager) -> Result<(), DbErr> { | ||
// This one is a bit special. The original migration was bugged by a performance issue. So | ||
// we need to replace that function if it was already present and passed the migration. But | ||
// We also need to replace the function in case the migration was not yet run. Because | ||
// otherwise, the migration would not pass. | ||
// | ||
// The strategy is to replace the original function with the new content, and re-apply it | ||
// with this migration. If the original migration did not yet pass, it would now. In any | ||
// case, this migration ensures the new content of the function from now on. | ||
manager | ||
.get_connection() | ||
.execute_unprepared(include_str!( | ||
"m0000650_alter_advisory_tracking/update_deprecated_advisory.sql" | ||
)) | ||
.await | ||
.map(|_| ())?; | ||
|
||
Ok(()) | ||
} | ||
|
||
async fn down(&self, _manager: &SchemaManager) -> Result<(), DbErr> { | ||
// As the original version of this function was flawed, we replaced the original content | ||
// and don't migrate back. | ||
Ok(()) | ||
} | ||
} |