-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
rsc: Add blob_id indexes for fks (#1624)
- Loading branch information
Showing
2 changed files
with
74 additions
and
0 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
72 changes: 72 additions & 0 deletions
72
rust/migration/src/m20240805_163520_create_blob_id_fk_indexes.rs
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_blob_id_idx | ||
ON output_file(blob_id) | ||
", | ||
) | ||
.await?; | ||
|
||
manager | ||
.get_connection() | ||
.execute_unprepared( | ||
" | ||
CREATE INDEX IF NOT EXISTS job_stdout_blob_id_idx | ||
ON job(stdout_blob_id) | ||
", | ||
) | ||
.await?; | ||
|
||
manager | ||
.get_connection() | ||
.execute_unprepared( | ||
" | ||
CREATE INDEX IF NOT EXISTS job_stderr_blob_id_idx | ||
ON job(stderr_blob_id) | ||
", | ||
) | ||
.await?; | ||
|
||
Ok(()) | ||
} | ||
|
||
async fn down(&self, manager: &SchemaManager) -> Result<(), DbErr> { | ||
manager | ||
.get_connection() | ||
.execute_unprepared( | ||
" | ||
DROP INDEX IF EXISTS output_file_blob_id_idx | ||
", | ||
) | ||
.await?; | ||
|
||
manager | ||
.get_connection() | ||
.execute_unprepared( | ||
" | ||
DROP INDEX IF EXISTS job_stdout_blob_id_idx | ||
", | ||
) | ||
.await?; | ||
|
||
manager | ||
.get_connection() | ||
.execute_unprepared( | ||
" | ||
DROP INDEX IF EXISTS job_stderr_blob_id_idx | ||
", | ||
) | ||
.await?; | ||
|
||
Ok(()) | ||
} | ||
} |