add some migs
This commit is contained in:
parent
6d97826050
commit
2afe008573
|
@ -1,3 +1,5 @@
|
|||
|
||||
|
||||
use actix_web::{HttpResponse, post};
|
||||
use actix_web::web::{Data, Json};
|
||||
use log::error;
|
||||
|
|
|
@ -12,6 +12,8 @@ pub mod m20230402_234025_create_table_totp_authenticators;
|
|||
pub mod m20230403_002256_create_table_auth_tokens;
|
||||
pub mod m20230403_142517_create_table_signing_cas;
|
||||
pub mod m20230403_173431_create_table_networks;
|
||||
mod m20230404_133809_create_table_roles;
|
||||
mod m20230404_133813_create_table_firewall_rules;
|
||||
|
||||
#[async_trait::async_trait]
|
||||
impl MigratorTrait for Migrator {
|
||||
|
@ -27,6 +29,8 @@ impl MigratorTrait for Migrator {
|
|||
Box::new(m20230403_002256_create_table_auth_tokens::Migration),
|
||||
Box::new(m20230403_142517_create_table_signing_cas::Migration),
|
||||
Box::new(m20230403_173431_create_table_networks::Migration),
|
||||
Box::new(m20230404_133809_create_table_roles::Migration),
|
||||
Box::new(m20230404_133813_create_table_firewall_rules::Migration),
|
||||
]
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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(Role::Table)
|
||||
.col(ColumnDef::new(Role::Id).string().not_null().primary_key())
|
||||
.col(ColumnDef::new(Role::Name).string().not_null())
|
||||
.col(ColumnDef::new(Role::Description).string().not_null())
|
||||
.col(ColumnDef::new(Role::Organization).string().not_null())
|
||||
.foreign_key(
|
||||
ForeignKey::create()
|
||||
.from(Role::Table, Role::Organization )
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
async fn down(&self, manager: &SchemaManager) -> Result<(), DbErr> {
|
||||
// Replace the sample below with your own migration scripts
|
||||
todo!();
|
||||
|
||||
manager
|
||||
.drop_table(Table::drop().table(Post::Table).to_owned())
|
||||
.await
|
||||
}
|
||||
}
|
||||
|
||||
/// Learn more at https://docs.rs/sea-query#iden
|
||||
#[derive(Iden)]
|
||||
pub enum Role {
|
||||
Table,
|
||||
Id,
|
||||
Name,
|
||||
Description,
|
||||
Organization
|
||||
}
|
|
@ -0,0 +1,48 @@
|
|||
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> {
|
||||
// Replace the sample below with your own migration scripts
|
||||
todo!();
|
||||
|
||||
manager
|
||||
.create_table(
|
||||
Table::create()
|
||||
.table(Post::Table)
|
||||
.if_not_exists()
|
||||
.col(
|
||||
ColumnDef::new(Post::Id)
|
||||
.integer()
|
||||
.not_null()
|
||||
.auto_increment()
|
||||
.primary_key(),
|
||||
)
|
||||
.col(ColumnDef::new(Post::Title).string().not_null())
|
||||
.col(ColumnDef::new(Post::Text).string().not_null())
|
||||
.to_owned(),
|
||||
)
|
||||
.await
|
||||
}
|
||||
|
||||
async fn down(&self, manager: &SchemaManager) -> Result<(), DbErr> {
|
||||
// Replace the sample below with your own migration scripts
|
||||
todo!();
|
||||
|
||||
manager
|
||||
.drop_table(Table::drop().table(Post::Table).to_owned())
|
||||
.await
|
||||
}
|
||||
}
|
||||
|
||||
/// Learn more at https://docs.rs/sea-query#iden
|
||||
#[derive(Iden)]
|
||||
enum Post {
|
||||
Table,
|
||||
Id,
|
||||
Title,
|
||||
Text,
|
||||
}
|
Loading…
Reference in New Issue