-
-
Notifications
You must be signed in to change notification settings - Fork 637
Open
Description
Motivation
The current definition of the length and name of the database field is not in one position, and when the name and length are modified, it is very inconvenient to modify the name and length.
Proposed Solutions
Suggestions be changed to the following
#[async_trait::async_trait]
impl MigrationTrait for Migration {
async fn up(&self, manager: &SchemaManager) -> Result<(), DbErr> {
manager
.create_table(
Table::create()
.table(SysApp::Table)
.if_not_exists()
.col(string(SysApp::AppId).primary_key())
.col(string_uniq(SysApp::AppCode, 255))
.col(string_uniq(SysApp::AppName, 255))
.col(string_null(SysApp::AppDesc, 255))
.col(string_null(SysApp::AppUrl))
.index(
Index::create().unique()
.name("UK_SYS_APP_CODE")
.col(SysApp::AppCode)
)
.to_owned(),
)
.await?;
}
}
#[derive(DeriveIden)]
pub enum SysApp {
#[sea_orm(iden = "SYS_APP")]
Table,
#[sea_orm(iden = "APP_ID", len=36)]
AppId,
#[sea_orm(iden = "APP_CODE", len=255)]
AppCode,
#[sea_orm(iden = "APP_NAME", len=255)]
AppName,
#[sea_orm(iden = "APP_DESC", len=255)]
AppDesc,
#[sea_orm(iden = "APP_URL")]
AppUrl,
}Additional Information
The current definition is as follows:
#[async_trait::async_trait]
impl MigrationTrait for Migration {
async fn up(&self, manager: &SchemaManager) -> Result<(), DbErr> {
manager
.create_table(
Table::create()
.table(SysApp::Table)
.if_not_exists()
.col(string_len(SysApp::AppId, 36).primary_key())
.col(string_len_uniq(SysApp::AppCode, 255))
.col(string_len_uniq(SysApp::AppName, 255))
.col(string_len_null(SysApp::AppDesc, 255))
.col(string_null(SysApp::AppUrl))
.index(
Index::create().unique()
.name("UK_SYS_APP_CODE")
.col(SysApp::AppCode)
)
.to_owned(),
)
.await?;
}
#[derive(DeriveIden)]
pub enum SysApp {
#[sea_orm(iden = "SYS_APP")]
Table,
#[sea_orm(iden = "APP_ID")]
AppId,
#[sea_orm(iden = "APP_CODE")]
AppCode,
#[sea_orm(iden = "APP_NAME")]
AppName,
#[sea_orm(iden = "APP_DESC")]
AppDesc,
#[sea_orm(iden = "APP_URL")]
AppUrl,
}Metadata
Metadata
Assignees
Labels
No labels