-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
rsc: Create indexes for outputs(job_id) (#1633)
- Loading branch information
Showing
3 changed files
with
77 additions
and
3 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
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> { | ||
manager | ||
.get_connection() | ||
.execute_unprepared( | ||
" | ||
CREATE INDEX IF NOT EXISTS output_file_job_id_idx | ||
ON output_file(job_id) | ||
", | ||
) | ||
.await?; | ||
|
||
manager | ||
.get_connection() | ||
.execute_unprepared( | ||
" | ||
CREATE INDEX IF NOT EXISTS output_dir_job_id_idx | ||
ON output_dir(job_id) | ||
", | ||
) | ||
.await?; | ||
|
||
manager | ||
.get_connection() | ||
.execute_unprepared( | ||
" | ||
CREATE INDEX IF NOT EXISTS output_symlink_job_id_idx | ||
ON output_symlink(job_id) | ||
", | ||
) | ||
.await?; | ||
|
||
Ok(()) | ||
} | ||
|
||
async fn down(&self, manager: &SchemaManager) -> Result<(), DbErr> { | ||
manager | ||
.get_connection() | ||
.execute_unprepared( | ||
" | ||
DROP INDEX IF EXISTS output_file_job_id_idx | ||
", | ||
) | ||
.await?; | ||
|
||
manager | ||
.get_connection() | ||
.execute_unprepared( | ||
" | ||
DROP INDEX IF EXISTS output_dir_job_id_idx | ||
", | ||
) | ||
.await?; | ||
|
||
manager | ||
.get_connection() | ||
.execute_unprepared( | ||
" | ||
DROP INDEX IF EXISTS output_symlink_job_id_idx | ||
", | ||
) | ||
.await?; | ||
|
||
Ok(()) | ||
} | ||
} |
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