Add is_highlighted and is_archived to project
This commit is contained in:
@@ -9,6 +9,7 @@ mod m20241030_002154_jobs;
|
||||
mod m20241030_024340_projects;
|
||||
mod m20241030_024830_data;
|
||||
mod m20241106_005545_project_thumbnails;
|
||||
mod m20241110_011041_add_is_highlighted_to_project;
|
||||
pub struct Migrator;
|
||||
|
||||
#[async_trait::async_trait]
|
||||
@@ -16,6 +17,7 @@ impl MigratorTrait for Migrator {
|
||||
fn migrations() -> Vec<Box<dyn MigrationTrait>> {
|
||||
vec![
|
||||
// inject-below
|
||||
Box::new(m20241110_011041_add_is_highlighted_to_project::Migration),
|
||||
Box::new(m20241106_005545_project_thumbnails::Migration),
|
||||
Box::new(m20241030_024830_data::Migration),
|
||||
Box::new(m20241030_024340_projects::Migration),
|
||||
|
@@ -0,0 +1,71 @@
|
||||
use sea_orm_migration::{prelude::*, schema::*};
|
||||
|
||||
#[derive(DeriveMigrationName)]
|
||||
pub struct Migration;
|
||||
|
||||
#[derive(DeriveIden)]
|
||||
enum Projects {
|
||||
Table,
|
||||
IsHighlighted,
|
||||
IsArchived,
|
||||
}
|
||||
|
||||
#[async_trait::async_trait]
|
||||
impl MigrationTrait for Migration {
|
||||
async fn up(&self, manager: &SchemaManager) -> Result<(), DbErr> {
|
||||
//
|
||||
// add column
|
||||
//
|
||||
manager
|
||||
.alter_table(
|
||||
Table::alter()
|
||||
.table(Projects::Table)
|
||||
.add_column_if_not_exists(boolean(Projects::IsHighlighted).default(false))
|
||||
.add_column_if_not_exists(boolean(Projects::IsArchived).default(false))
|
||||
.to_owned(),
|
||||
)
|
||||
.await
|
||||
|
||||
//
|
||||
// delete column
|
||||
//
|
||||
/*
|
||||
manager
|
||||
.alter_table(
|
||||
Table::alter()
|
||||
.table(Movies::Table)
|
||||
.drop_column(Movies::Rating)
|
||||
.to_owned(),
|
||||
)
|
||||
.await
|
||||
*/
|
||||
|
||||
//
|
||||
// create index
|
||||
//
|
||||
/*
|
||||
manager
|
||||
.create_index(
|
||||
Index::create()
|
||||
.name("idx-movies-rating")
|
||||
.table(Movies::Table)
|
||||
.col(Movies::Rating)
|
||||
.to_owned(),
|
||||
)
|
||||
.await;
|
||||
*/
|
||||
}
|
||||
|
||||
async fn down(&self, manager: &SchemaManager) -> Result<(), DbErr> {
|
||||
manager
|
||||
.alter_table(
|
||||
Table::alter()
|
||||
.table(Projects::Table)
|
||||
.drop_column(Projects::IsHighlighted)
|
||||
.drop_column(Projects::IsArchived)
|
||||
.to_owned(),
|
||||
)
|
||||
.await
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user