mirror of
https://git.alemi.dev/dashboard.git
synced 2024-11-21 23:14:53 +01:00
feat: db migration to remove query_x and query_y
This commit is contained in:
parent
d7856a921e
commit
fc6926816b
2 changed files with 89 additions and 0 deletions
|
@ -4,6 +4,7 @@ mod m20220101_000001_create_table;
|
||||||
mod m20221030_192706_add_last_update;
|
mod m20221030_192706_add_last_update;
|
||||||
mod m20221102_232244_add_join_table;
|
mod m20221102_232244_add_join_table;
|
||||||
mod m20221102_232858_remove_unused_columns;
|
mod m20221102_232858_remove_unused_columns;
|
||||||
|
mod m20221106_211436_remove_query_x;
|
||||||
|
|
||||||
pub struct Migrator;
|
pub struct Migrator;
|
||||||
|
|
||||||
|
@ -15,6 +16,7 @@ impl MigratorTrait for Migrator {
|
||||||
Box::new(m20221030_192706_add_last_update::Migration),
|
Box::new(m20221030_192706_add_last_update::Migration),
|
||||||
Box::new(m20221102_232244_add_join_table::Migration),
|
Box::new(m20221102_232244_add_join_table::Migration),
|
||||||
Box::new(m20221102_232858_remove_unused_columns::Migration),
|
Box::new(m20221102_232858_remove_unused_columns::Migration),
|
||||||
|
Box::new(m20221106_211436_remove_query_x::Migration),
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
87
migration/src/m20221106_211436_remove_query_x.rs
Normal file
87
migration/src/m20221106_211436_remove_query_x.rs
Normal file
|
@ -0,0 +1,87 @@
|
||||||
|
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
|
||||||
|
.alter_table(
|
||||||
|
Table::alter()
|
||||||
|
.table(Metrics::Table)
|
||||||
|
.drop_column(Metrics::QueryX)
|
||||||
|
.to_owned()
|
||||||
|
).await?;
|
||||||
|
|
||||||
|
manager
|
||||||
|
.alter_table(
|
||||||
|
Table::alter()
|
||||||
|
.table(Metrics::Table)
|
||||||
|
.rename_column(Metrics::QueryY, Metrics::Query)
|
||||||
|
.to_owned()
|
||||||
|
).await?;
|
||||||
|
|
||||||
|
manager
|
||||||
|
.alter_table(
|
||||||
|
Table::alter()
|
||||||
|
.table(Panels::Table)
|
||||||
|
.drop_column(Panels::Timeserie)
|
||||||
|
.to_owned()
|
||||||
|
).await?;
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn down(&self, manager: &SchemaManager) -> Result<(), DbErr> {
|
||||||
|
manager
|
||||||
|
.alter_table(
|
||||||
|
Table::alter()
|
||||||
|
.table(Metrics::Table)
|
||||||
|
.rename_column(Metrics::Query, Metrics::QueryY)
|
||||||
|
.to_owned()
|
||||||
|
).await?;
|
||||||
|
|
||||||
|
manager.
|
||||||
|
alter_table(
|
||||||
|
Table::alter()
|
||||||
|
.table(Metrics::Table)
|
||||||
|
.add_column(
|
||||||
|
ColumnDef::new(Metrics::QueryX)
|
||||||
|
.float()
|
||||||
|
.not_null()
|
||||||
|
.default(0.0)
|
||||||
|
)
|
||||||
|
.to_owned()
|
||||||
|
).await?;
|
||||||
|
|
||||||
|
manager.
|
||||||
|
alter_table(
|
||||||
|
Table::alter()
|
||||||
|
.table(Panels::Table)
|
||||||
|
.add_column(
|
||||||
|
ColumnDef::new(Panels::Timeserie)
|
||||||
|
.boolean()
|
||||||
|
.not_null()
|
||||||
|
.default(true)
|
||||||
|
)
|
||||||
|
.to_owned()
|
||||||
|
).await?;
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Iden)]
|
||||||
|
enum Metrics {
|
||||||
|
Table,
|
||||||
|
QueryX,
|
||||||
|
QueryY,
|
||||||
|
Query,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Iden)]
|
||||||
|
enum Panels {
|
||||||
|
Table,
|
||||||
|
Timeserie,
|
||||||
|
}
|
Loading…
Reference in a new issue