-
Notifications
You must be signed in to change notification settings - Fork 44
Expand file tree
/
Copy pathm0002140_p2p_right_index.rs
More file actions
53 lines (46 loc) · 1.39 KB
/
m0002140_p2p_right_index.rs
File metadata and controls
53 lines (46 loc) · 1.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
use sea_orm_migration::prelude::*;
#[derive(DeriveMigrationName)]
pub struct Migration;
#[async_trait::async_trait]
#[allow(deprecated)]
impl MigrationTrait for Migration {
async fn up(&self, manager: &SchemaManager) -> Result<(), DbErr> {
manager
.create_index(
Index::create()
.if_not_exists()
.table(PackageRelatesToPackage::Table)
.name(Indexes::IdxPackageRelatesToPackageRightId.to_string())
.col(PackageRelatesToPackage::SbomId)
.col(PackageRelatesToPackage::Relationship)
.col(PackageRelatesToPackage::RightNodeId)
.to_owned(),
)
.await?;
Ok(())
}
async fn down(&self, manager: &SchemaManager) -> Result<(), DbErr> {
// Drop indexes in reverse order
manager
.drop_index(
Index::drop()
.if_exists()
.table(PackageRelatesToPackage::Table)
.name(Indexes::IdxPackageRelatesToPackageRightId.to_string())
.to_owned(),
)
.await?;
Ok(())
}
}
#[derive(DeriveIden)]
enum Indexes {
IdxPackageRelatesToPackageRightId,
}
#[derive(DeriveIden)]
enum PackageRelatesToPackage {
Table,
SbomId,
Relationship,
RightNodeId,
}