feat[migration]!: added persistence table
This commit is contained in:
parent
5f8780ce2f
commit
3a815d8536
5 changed files with 71 additions and 8 deletions
|
@ -2,6 +2,7 @@ pub use sea_orm_migration::prelude::*;
|
|||
|
||||
mod m20220101_000001_create_table;
|
||||
mod m20230123_000947_skin_table;
|
||||
mod m20230306_135803_persistence_table;
|
||||
|
||||
pub struct Migrator;
|
||||
|
||||
|
@ -11,6 +12,7 @@ impl MigratorTrait for Migrator {
|
|||
vec![
|
||||
Box::new(m20220101_000001_create_table::Migration),
|
||||
Box::new(m20230123_000947_skin_table::Migration),
|
||||
Box::new(m20230306_135803_persistence_table::Migration),
|
||||
]
|
||||
}
|
||||
}
|
||||
|
|
41
migration/src/m20230306_135803_persistence_table.rs
Normal file
41
migration/src/m20230306_135803_persistence_table.rs
Normal file
|
@ -0,0 +1,41 @@
|
|||
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
|
||||
.create_table(
|
||||
Table::create()
|
||||
.table(Persistence::Table)
|
||||
.if_not_exists()
|
||||
.col(
|
||||
ColumnDef::new(Persistence::Id)
|
||||
.integer()
|
||||
.not_null()
|
||||
.auto_increment()
|
||||
.primary_key(),
|
||||
)
|
||||
.col(ColumnDef::new(Persistence::Secret).string().not_null())
|
||||
.col(ColumnDef::new(Persistence::LastEdit).date_time().not_null())
|
||||
.to_owned(),
|
||||
)
|
||||
.await
|
||||
}
|
||||
|
||||
async fn down(&self, manager: &SchemaManager) -> Result<(), DbErr> {
|
||||
manager
|
||||
.drop_table(Table::drop().table(Persistence::Table).to_owned())
|
||||
.await
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Iden)]
|
||||
enum Persistence {
|
||||
Table,
|
||||
Id,
|
||||
Secret,
|
||||
LastEdit,
|
||||
}
|
|
@ -1,7 +1,8 @@
|
|||
//! `SeaORM` Entity. Generated by sea-orm-codegen 0.10.7
|
||||
//! `SeaORM` Entity. Generated by sea-orm-codegen 0.11.0
|
||||
|
||||
pub mod prelude;
|
||||
|
||||
pub mod persistence;
|
||||
pub mod property;
|
||||
pub mod token;
|
||||
pub mod user;
|
||||
|
|
18
src/entities/persistence.rs
Normal file
18
src/entities/persistence.rs
Normal file
|
@ -0,0 +1,18 @@
|
|||
//! `SeaORM` Entity. Generated by sea-orm-codegen 0.11.0
|
||||
|
||||
use chrono::{Utc, DateTime};
|
||||
use sea_orm::entity::prelude::*;
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
|
||||
#[sea_orm(table_name = "persistence")]
|
||||
pub struct Model {
|
||||
#[sea_orm(primary_key)]
|
||||
pub id: i32,
|
||||
pub secret: String,
|
||||
pub last_edit: DateTime<Utc>,
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
|
||||
pub enum Relation {}
|
||||
|
||||
impl ActiveModelBehavior for ActiveModel {}
|
|
@ -1,5 +1,6 @@
|
|||
//! `SeaORM` Entity. Generated by sea-orm-codegen 0.10.7
|
||||
//! `SeaORM` Entity. Generated by sea-orm-codegen 0.11.0
|
||||
|
||||
pub use super::persistence::Entity as Persistence;
|
||||
pub use super::property::Entity as Property;
|
||||
pub use super::token::Entity as Token;
|
||||
pub use super::user::Entity as User;
|
||||
|
|
Loading…
Reference in a new issue