-
In this example there is a test to check that a table made with SeaORM syntax is correct. I want to use a test like that in a code base very similar to the one from the SeaORM tutorial.
When I run
|
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
Hey @JediMaster25, welcome! I don't think you can fn file_table() -> TableCreateStatement {
Table::create()
.table(File::Table)
.col(
ColumnDef::new(File::Id)
.integer()
.not_null()
.auto_increment()
.primary_key(),
)
.col(ColumnDef::new(File::rating).double())
.to_owned()
}
fn file_name_table() -> TableCreateStatement {
Table::create()
.table(FileName::Table)
.col(
ColumnDef::new(FileName::Id)
.integer()
.not_null()
.auto_increment()
.primary_key(),
)
.col(
ColumnDef::new(FileName::Name)
.text()
.not_null(),
)
.col(ColumnDef::new(FileName::Lang)
.text()
.not_null(),
)
.col(
ColumnDef::new(FileName::FileId)
.integer()
.not_null(),
)
.ForeignKey(
ForeignKey::new()
.name("fk_file_id")
.references(File::Id)
.on_delete(OnDelete::Cascade),
)
.to_owned()
} Also, it should be impl MigrationName for Migration {
fn name(&self) -> &str {
"m_20220726_000001_create_schema"
}
}
#[async_trait::async_trait]
impl MigrationTrait for Migration {
async fn up(&self, manager: &SchemaManager) -> Result<(), DbErr> {
manager
.create_table(file_table)
.create_table(file_name_table)
.await
}
async fn down(&self, manager: &SchemaManager) -> Result<(), DbErr> {
manager
.drop_table(Table::drop().table(File::Table).to_owned())
.await
}
} |
Beta Was this translation helpful? Give feedback.
-
Thanks. Here is the corrected code
|
Beta Was this translation helpful? Give feedback.
Thanks.
Here is the corrected code
./Cargo.toml
./src/main.rs