-
Lets say I defined an entity like this:
And I created a migration to create a table for these entities with
That table will have the name Lets say I want to rename this table to its singular name
Executing this works, but every access to the entity than immediately complaints that the table Changing the annotation to So the only way to make that rename operation work is by simply using
and not relying on the type definition at all. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
Sorry for the confusion, we now updated the examples. Basically you can do something like #[derive(Iden)]
enum Post {
Table,
Id,
Title,
Text,
} |
Beta Was this translation helpful? Give feedback.
-
struct TableName(String);
impl sea_orm::Iden for TableName {
fn unquoted(&self, s: &mut dyn fmt::Write) {
write!(s, "{}", self.0).unwrap();
}
}
let mut stmt = schema.create_table_from_entity(course::Entity);
// Change the table name here
stmt.table(TableName("new_table_name".to_owned())); |
Beta Was this translation helpful? Give feedback.
Sorry for the confusion, we now updated the examples.
#785
Basically you can do something like