- erp-core: error types, shared types, event bus, ErpModule trait - erp-server: config loading, database/Redis connections, migrations - erp-server/migration: tenants table with SeaORM - apps/web: Vite + React 18 + TypeScript + Ant Design 5 + TailwindCSS - Web frontend: main layout with sidebar, header, routing - Docker: PostgreSQL 16 + Redis 7 development environment - All workspace crates compile successfully (cargo check passes)
75 lines
2.3 KiB
Rust
75 lines
2.3 KiB
Rust
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(Tenant::Table)
|
|
.if_not_exists()
|
|
.col(
|
|
ColumnDef::new(Tenant::Id)
|
|
.uuid()
|
|
.not_null()
|
|
.primary_key(),
|
|
)
|
|
.col(ColumnDef::new(Tenant::Name).string().not_null())
|
|
.col(
|
|
ColumnDef::new(Tenant::Code)
|
|
.string()
|
|
.not_null()
|
|
.unique_key(),
|
|
)
|
|
.col(
|
|
ColumnDef::new(Tenant::Status)
|
|
.string()
|
|
.not_null()
|
|
.default("active"),
|
|
)
|
|
.col(ColumnDef::new(Tenant::Settings).json().null())
|
|
.col(
|
|
ColumnDef::new(Tenant::CreatedAt)
|
|
.timestamp_with_time_zone()
|
|
.not_null()
|
|
.default(Expr::current_timestamp()),
|
|
)
|
|
.col(
|
|
ColumnDef::new(Tenant::UpdatedAt)
|
|
.timestamp_with_time_zone()
|
|
.not_null()
|
|
.default(Expr::current_timestamp()),
|
|
)
|
|
.col(
|
|
ColumnDef::new(Tenant::DeletedAt)
|
|
.timestamp_with_time_zone()
|
|
.null(),
|
|
)
|
|
.to_owned(),
|
|
)
|
|
.await
|
|
}
|
|
|
|
async fn down(&self, manager: &SchemaManager) -> Result<(), DbErr> {
|
|
manager
|
|
.drop_table(Table::drop().table(Tenant::Table).to_owned())
|
|
.await
|
|
}
|
|
}
|
|
|
|
#[derive(DeriveIden)]
|
|
enum Tenant {
|
|
Table,
|
|
Id,
|
|
Name,
|
|
Code,
|
|
Status,
|
|
Settings,
|
|
CreatedAt,
|
|
UpdatedAt,
|
|
DeletedAt,
|
|
}
|