| 131 | } |
| 132 | |
| 133 | pub(crate) fn create_index_from_entity<E>( |
| 134 | entity: E, |
| 135 | _backend: DbBackend, |
| 136 | ) -> Vec<IndexCreateStatement> |
| 137 | where |
| 138 | E: EntityTrait, |
| 139 | { |
| 140 | let mut vec = Vec::new(); |
| 141 | for column in E::Column::iter() { |
| 142 | let column_def = column.def(); |
| 143 | if !column_def.indexed { |
| 144 | continue; |
| 145 | } |
| 146 | let stmt = Index::create() |
| 147 | .name(format!("idx-{}-{}", entity.to_string(), column.to_string())) |
| 148 | .table(entity) |
| 149 | .col(column) |
| 150 | .to_owned(); |
| 151 | vec.push(stmt) |
| 152 | } |
| 153 | vec |
| 154 | } |
| 155 | |
| 156 | pub(crate) fn create_table_from_entity<E>(entity: E, backend: DbBackend) -> TableCreateStatement |
| 157 | where |